Created
June 23, 2009 14:50
-
-
Save kodi/134574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Class Osoba{ | |
public $ime; | |
function podesiIme($ime){ | |
$this->ime=$ime; | |
} | |
function pozdrav(){ | |
echo 'Dobar dan, ja sam '.$this->ime.'.'; | |
} | |
} | |
Class Lopov extends Osoba{ | |
public $opisZanimanja='profesionalni lopov!'; | |
function pozdrav(){ | |
echo 'Dobar dan, ja sam '.$this->ime.', '.$this->opisZanimanja; | |
} | |
} | |
Class Politicar extends Lopov{ | |
function __construct(){ | |
$this->opisZanimanja='politicar i gospodin chovek!'; | |
} | |
} | |
$osoba1=New Osoba(); | |
$osoba1->podesiIme('Mika'); | |
$osoba1->pozdrav(); // vraca: Dobar dan, ja sam Mika. | |
echo '<br>'; | |
$osoba2=New Lopov(); | |
$osoba2->podesiIme('Pera'); | |
$osoba2->pozdrav(); // vraca: Dobar dan, ja sam Pera, profesionalni lopov! | |
echo '<br>'; | |
$osoba3=New Politicar(); | |
$osoba3->podesiIme('Zika'); | |
$osoba3->pozdrav(); // vraca: Dobar dan, ja sam Zika, politicar i gospodin chovek! | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment