inherit Classes - I dont get this:
Posted: Fri Sep 16, 2005 4:08 am
Hi!
F.E I have this class:
and now i want to inherit it like
so how can i change through "Animal" one of "Person" functions ? or is this not possible?
f.e. ass you can see i made a function in "Person" which will store something in "Person's" variables.
how can i extend that for "Animal"?
example:
or:
i dont get this
thanks
F.E I have this class:
Code: Select all
class Person{
var $name;
var $age;
var $hairs;
function Person($a, $b, $c){
$this->name = $a;
$this->age = $b;
$this->hairs = $c;
}
function Say(){
echo "Name:".$this->name."<br>Age:".$this->age."<br>Hairs:".$this->hairs;
}
}Code: Select all
class Animal extends Person{
var $color;
}so how can i change through "Animal" one of "Person" functions ? or is this not possible?
f.e. ass you can see i made a function in "Person" which will store something in "Person's" variables.
how can i extend that for "Animal"?
example:
Code: Select all
$p1 = new Person("Tom", 21, "brown");
$a1 = new Animal("Bonzo", 5, "yellow", "white");???????Code: Select all
$p1->say(); // Tom 21 brown
$a1->say(); // Bonzo 5 yello, white?????????????thanks