class CAdresa {
// data
var $Jmeno, $Prijmeni, $Ulice, $Obec, $PSC;
// konstruktor má stejné jméno jako třída
function CAdresa($jm="X",$pr="Y",$ul="?",$ob="?",$ps="?") {
$this->Jmeno = $jm;
$this->Prijmeni = $pr;
$this->Ulice = $ul;
$this->Obec = $ob;
$this->PSC = $ps;
}
// funkce vypisuje data
function Tisk($format=0) {
if ($format == 0) {
echo $this->Jmeno." ".$this->Prijmeni." ... ";
echo $this->Ulice.", ".$this->Obec.", ".$this->PSC."
";
}
elseif ($format == 1) {
echo $this->Jmeno." ".$this->Prijmeni."
";
echo $this->Ulice."
";
echo $this->PSC.", ".$this->Obec."
";
}
}
//
}
class CFiremniAdresa extends CAdresa {
var $Nazev;
function CFiremniAdresa($na,$ul,$ob,$ps) {
$this->CAdresa("","",$ul,$ob,$ps);
$this->Nazev = $na;
}
function Tisk() { //nelze využít předkovu funkci
echo $this->Nazev." : ";
echo $this->Ulice.", ".$this->Obec.", ".$this->PSC."
";
}
}
?>
"; $firma = new CFiremniAdresa("Pieta","Hřbitovní 1","Plzeň","321 12"); $firma->Tisk(); ?>