11.09.2018 Views

Aprender a desarrollar un sitio Web con PHP y MySQL

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

accesos<br />

public f<strong>un</strong>ction getType()<br />

{<br />

if ($this->vive_en_el_mar){<br />

return "vive_en_el_mar";<br />

}<br />

else if ($this->vive_en_el_mar===falso){<br />

return "no_vive_en_el_mar";<br />

}else {return "";}<br />

}<br />

public f<strong>un</strong>ction setType($vive_en_el_mar)<br />

{<br />

$this->vive_en_el_mar = $vive_en_el_mar;<br />

//escrito en el atributo vive_en_el_mar<br />

}<br />

//método<br />

public f<strong>un</strong>ction nadar()<br />

{<br />

echo "Nado ";<br />

}<br />

}<br />

?><br />

De la misma manera, cree <strong>un</strong> archivo Gato.class.php:<br />

<br />

}<br />

Las clases Gato y Pez, que heredan de la clase Animal, tienen acceso a los atributos públicos de la<br />

clase Animal.<br />

La página uso.php:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!