Skip to content

Instantly share code, notes, and snippets.

@kodi kodi/gist:134574
Created Jun 23, 2009

Embed
What would you like to do?
<?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
You can’t perform that action at this time.