<?php

# inclue classe XMLBase
include_once 'classes/XMLBase.class.php';
class Cachorro extends XMLBase
{
    # método construtor
    function __construct($nome, $idade, $raca)
    {
        $this->nome = $nome;
        $this->idade = $idade;
        $this->raca = $raca;
    }
}
$toto = new Cachorro('Totó', 10, 'Fox Terrier');
$vava = new Cachorro('Daba', 8, 'Dálmata');
echo $toto->toXml();
echo $vava->toXml();
Beispiel #2
0
    public function emitirSom()
    {
        echo "Nao sei, Depende";
    }
    public function dormir()
    {
        echo "ZZZzzZZzZZzzzHHzz";
    }
}
class Gato extends Animal
{
    public function emitirSom()
    {
        echo "Miau MIAU miaU";
    }
}
class Cachorro extends Animal
{
    public function emitirSom()
    {
        echo "AU AU Au Au";
    }
}
// GATO
$g = new Gato();
$g->dormir();
$g->emitirSom();
// CACHORRO
$c = new Cachorro();
$g->dormir();
$c->emitirSom();
Beispiel #3
0
    }
}
class Gato extends Animal
{
    /*
    	Sou obrigado a sobreescrever o metodo 
    	emitirSomm poes Animal e abstrato 
    	e Gato e Concreto 
    */
    public function emitirSom()
    {
        echo "MIAU";
    }
}
$g = new Gato();
$g->dormir();
$g->emitirSom();
echo "<br>";
$c = new Cachorro();
$c->dormir();
$c->emitirSom();
?>

/*

	contante nao se usa com o $this->
	e sim com o nomeclasse::nomeConstante

	ex.: Brincavel::QTD_BRINCADEIRA_DIA

*/
Beispiel #4
0
 */
class Cachorro
{
    private $apelido;
    private $tipo;
    private $raca;
    public function Cachorro()
    {
    }
    public function late()
    {
        return "Au au";
    }
    public function setApelido($apelido)
    {
        $this->apelido = $apelido;
    }
    public function getApelido()
    {
        return $this->apelido;
    }
}
/**
 *
 */
class Chacchorao extends Cachorro
{
}
$grande = new Cachorro();
$grande->setApelido("Lobo");
echo $grande->getApelido();
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php 
include_once './XMLBase.class.php';
class Cachorro extends XMLBase
{
    function __construct($nome, $idade, $raca)
    {
        $this->nome = $nome;
        $this->idade = $idade;
        $this->raca = $raca;
    }
}
$toto = new Cachorro('Totó', 5, 'Pitbull');
$vava = new Cachorro('Vavá', 3, 'Dog Alemão');
echo $toto->toXML();
echo $vava->toXML();
?>
    </body>
</html>