Skip to content

Instantly share code, notes, and snippets.

@kodi
Created June 23, 2009 14:50
Show Gist options
  • Save kodi/134574 to your computer and use it in GitHub Desktop.
Save kodi/134574 to your computer and use it in GitHub Desktop.
<?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