Home Foros Foro dudas Foro de PHP/MySql Video 24 – No me reconoce variables ni propiedades

Video 24 – No me reconoce variables ni propiedades

Viendo 1 entrada (de un total de 1)
  • Autor
    Entradas
  • #11474

    eduardo
    Participante

    Buenas tardes

    Les agradecere si me pueden ayudar con este error que me aparece.

    Estoy realizando el ejercicio del Video 24 para reutilizar el codigo de las clases, pero al ejecutar el archivo php me salen los siguientes errores:

    <b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>Notice</b><span style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>: Undefined variable: ruedas in </span><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>C:\xampp\htdocs\ejercicios\poo\poo_24.php</b><span style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”> on line </span><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>17</b><br style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;” /><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>Notice</b><span style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>: Undefined property: Coche::$ in </span><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>C:\xampp\htdocs\ejercicios\poo\poo_24.php</b><span style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”> on line </span><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>17</b><br style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;” /><span style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>El Mazda tieneruedas.</span><br style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;” /><br style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;” /><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>Notice</b><span style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>: Undefined variable: ruedas in </span><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>C:\xampp\htdocs\ejercicios\poo\poo_24.php</b><span style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”> on line </span><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>18</b><br style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;” /><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>Notice</b><span style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>: Undefined property: Camion::$ in </span><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>C:\xampp\htdocs\ejercicios\poo\poo_24.php</b><span style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”> on line </span><b style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>18</b><br style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;” /><span style=”color: #000000; font-family: ‘Times New Roman’; font-size: medium;”>El Pegaso tieneruedas.</span>

    Aparentemente seria porque no reconoce la variable $ruedas ni las clases Coche y Camion … pero no encuentre el motivo.

    Los 2 archivos que estoy utilizando utilizamos “poo_24.php” y “vehiculos.php” se encuentran en la misma carpeta.

    El codigo del archivo poo_24.php es el siguiente:
    <div style=”color: #000000; font-family: Consolas, ‘Courier New’, monospace; font-size: 14px; line-height: 19px; white-space: pre;”>
    <div><span style=”color: #800000;”><!DOCTYPE</span> <span style=”color: #ff0000;”>html</span><span style=”color: #800000;”>></span></div>
    <div><span style=”color: #800000;”><html</span> <span style=”color: #ff0000;”>lang</span>=<span style=”color: #0000ff;”>”en”</span><span style=”color: #800000;”>></span></div>
    <div><span style=”color: #800000;”><head></span></div>
    <div>    <span style=”color: #800000;”><meta</span> <span style=”color: #ff0000;”>charset</span>=<span style=”color: #0000ff;”>”UTF-8″</span><span style=”color: #800000;”>></span></div>
    <div>    <span style=”color: #800000;”><meta</span> <span style=”color: #ff0000;”>name</span>=<span style=”color: #0000ff;”>”viewport”</span> <span style=”color: #ff0000;”>content</span>=<span style=”color: #0000ff;”>”width=device-width, initial-scale=1.0″</span><span style=”color: #800000;”>></span></div>
    <div>    <span style=”color: #800000;”><title></span>Document<span style=”color: #800000;”></title></span></div>
    <div><span style=”color: #800000;”></head></span></div>
    <div><span style=”color: #800000;”><body></span></div>
    <div></div>
    <div><span style=”color: #800000;”><?php</span></div>
    <div>    <span style=”color: #af00db;”>include</span> (<span style=”color: #a31515;”>’vehiculos.php'</span>);</div>
    <div>    <span style=”color: #001080;”>$mazda</span>=<span style=”color: #0000ff;”>new</span> <span style=”color: #267f99;”>Coche</span>;</div>
    <div>    <span style=”color: #001080;”>$pegaso</span>=<span style=”color: #0000ff;”>new</span> <span style=”color: #267f99;”>Camion</span>;</div>
    <div>    <span style=”color: #795e26;”>echo</span> <span style=”color: #a31515;”>”El Mazda tiene”</span> . <span style=”color: #001080;”>$mazda</span>-><span style=”color: #001080;”>$ruedas</span> . <span style=”color: #a31515;”>”ruedas.<br>”</span>;</div>
    <div>    <span style=”color: #795e26;”>echo</span> <span style=”color: #a31515;”>”El Pegaso tiene”</span> . <span style=”color: #001080;”>$pegaso</span>-><span style=”color: #001080;”>$ruedas</span> . <span style=”color: #a31515;”>”ruedas.<br>”</span>;</div>
    <div><span style=”color: #800000;”>?</span><span style=”color: #800000;”>></span></div>
    <div><span style=”color: #800000;”></body></span></div>
    <div><span style=”color: #800000;”></html></span></div>
    </div>
    <div></div>
    <div>Y el codigo del archivo vehiculos.php es el siguiente:</div>
    <div>
    <div style=”color: #000000; font-family: Consolas, ‘Courier New’, monospace; font-size: 14px; line-height: 19px; white-space: pre;”>
    <div><span style=”color: #800000;”><?php</span></div>
    <div>    <span style=”color: #008000;”>//Creamos la clase Coche</span></div>
    <div></div>
    <div>     <span style=”color: #0000ff;”>class</span> <span style=”color: #267f99;”>Coche</span>{</div>
    <div>        <span style=”color: #0000ff;”>var</span> <span style=”color: #001080;”>$ruedas</span>;</div>
    <div>        <span style=”color: #0000ff;”>var</span> <span style=”color: #001080;”>$color</span>;</div>
    <div>        <span style=”color: #0000ff;”>var</span> <span style=”color: #001080;”>$motor</span>;</div>
    <div>        <span style=”color: #0000ff;”>function</span> <span style=”color: #795e26;”>Coche</span>() {</div>
    <div>            <span style=”color: #0000ff;”>$this</span>-><span style=”color: #001080;”>ruedas</span>=<span style=”color: #098658;”>4</span>;</div>
    <div>            <span style=”color: #0000ff;”>$this</span>-><span style=”color: #001080;”>color</span>=<span style=”color: #a31515;”>””</span>;</div>
    <div>            <span style=”color: #0000ff;”>$this</span>-><span style=”color: #001080;”>motor</span>=<span style=”color: #098658;”>1600</span>;</div>
    <div></div>
    <div>        }</div>
    <div></div>
    <div>        <span style=”color: #0000ff;”>function</span> <span style=”color: #795e26;”>arrancar</span>() {</div>
    <div>            <span style=”color: #795e26;”>echo</span> <span style=”color: #a31515;”>”Estoy arrancando <br>”</span>;</div>
    <div>        }</div>
    <div>        <span style=”color: #0000ff;”>function</span> <span style=”color: #795e26;”>girar</span>() {</div>
    <div>            <span style=”color: #795e26;”>echo</span> <span style=”color: #a31515;”>”Estoy girando <br>”</span>;</div>
    <div>        }</div>
    <div>        <span style=”color: #0000ff;”>function</span> <span style=”color: #795e26;”>frenar</span>() {</div>
    <div>            <span style=”color: #795e26;”>echo</span> <span style=”color: #a31515;”>”Estoy frenando <br>”</span>;</div>
    <div>        }</div>
    <div>        <span style=”color: #0000ff;”>function</span> <span style=”color: #795e26;”>establece_color</span>(<span style=”color: #001080;”>$color_coche</span>,<span style=”color: #001080;”> $nombre_coche</span>) {</div>
    <div>            <span style=”color: #0000ff;”>$this</span>-><span style=”color: #001080;”>color</span>=<span style=”color: #001080;”>$color_coche</span>;      <span style=”color: #008000;”>//asignamos a la variable color, el parametro que recibiremos en $color_coche</span></div>
    <div>            <span style=”color: #795e26;”>echo</span> <span style=”color: #a31515;”>”El color de “</span> . <span style=”color: #001080;”>$nombre_coche</span> . <span style=”color: #a31515;”>” es “</span> . <span style=”color: #0000ff;”>$this</span>-><span style=”color: #001080;”>color</span> . <span style=”color: #a31515;”>”<br>”</span>;</div>
    <div>        }</div>
    <div>    }</div>
    <div> <span style=”color: #008000;”>//———————————————————————————————————————</span></div>
    <div></div>
    <div> <span style=”color: #008000;”>//Creamos la clase Camion</span></div>
    <div> <span style=”color: #0000ff;”>class</span> <span style=”color: #267f99;”>Camion</span>{</div>
    <div>    <span style=”color: #0000ff;”>var</span> <span style=”color: #001080;”>$ruedas</span>;</div>
    <div>    <span style=”color: #0000ff;”>var</span> <span style=”color: #001080;”>$color</span>;</div>
    <div>    <span style=”color: #0000ff;”>var</span> <span style=”color: #001080;”>$motor</span>;</div>
    <div>       <span style=”color: #0000ff;”>function</span> <span style=”color: #795e26;”>Camion</span>() {</div>
    <div>        <span style=”color: #0000ff;”>$this</span>-><span style=”color: #001080;”>ruedas</span>=<span style=”color: #098658;”>8</span>;</div>
    <div>        <span style=”color: #0000ff;”>$this</span>-><span style=”color: #001080;”>color</span>=<span style=”color: #a31515;”>””</span>;</div>
    <div>        <span style=”color: #0000ff;”>$this</span>-><span style=”color: #001080;”>motor</span>=<span style=”color: #098658;”>2600</span>;</div>
    <div></div>
    <div>    }</div>
    <div></div>
    <div>    <span style=”color: #0000ff;”>function</span> <span style=”color: #795e26;”>arrancar</span>() {</div>
    <div>        <span style=”color: #795e26;”>echo</span> <span style=”color: #a31515;”>”Estoy arrancando <br>”</span>;</div>
    <div>    }</div>
    <div>    <span style=”color: #0000ff;”>function</span> <span style=”color: #795e26;”>girar</span>() {</div>
    <div>        <span style=”color: #795e26;”>echo</span> <span style=”color: #a31515;”>”Estoy girando <br>”</span>;</div>
    <div>    }</div>
    <div>    <span style=”color: #0000ff;”>function</span> <span style=”color: #795e26;”>frenar</span>() {</div>
    <div>        <span style=”color: #795e26;”>echo</span> <span style=”color: #a31515;”>”Estoy frenando <br>”</span>;</div>
    <div>    }</div>
    <div>    <span style=”color: #0000ff;”>function</span> <span style=”color: #795e26;”>establece_color</span>(<span style=”color: #001080;”>$color_coche</span>,<span style=”color: #001080;”> $nombre_coche</span>) {</div>
    <div>        <span style=”color: #0000ff;”>$this</span>-><span style=”color: #001080;”>color</span>=<span style=”color: #001080;”>$color_coche</span>;</div>
    <div>        <span style=”color: #795e26;”>echo</span> <span style=”color: #a31515;”>”El color de “</span> . <span style=”color: #001080;”>$nombre_coche</span> . <span style=”color: #a31515;”>” es “</span> . <span style=”color: #0000ff;”>$this</span>-><span style=”color: #001080;”>color</span> . <span style=”color: #a31515;”>”<br>”</span>;</div>
    <div>    }</div>
    <div>}</div>
    <div><span style=”color: #800000;”>?</span><span style=”color: #800000;”>></span></div>
    <div></div>
    </div>
    <div>Desde ya les agradezco mucho la ayuda asi puedo continuar.</div>
    <div>Saludos</div>
    </div>

Viendo 1 entrada (de un total de 1)
  • Debes estar registrado para responder a este debate.