Let me start right off the code:
<?php
class Father{
function Father(){
echo 'A wild Father appears..';
}
function live(){
echo 'Some Father feels alive!';
}
}
class Child{
private $parent;
function Child($p){
echo 'A child is born :)';
}
function setParent($p){
$parent = $p;
}
function dance(){
echo 'The child is dancing, when ';
$parent -> live();
}
}
$p = new Father();
$p -> live();
$c = new Child($p);
$c -> dance();
?>
When running this I get an error on Line 24 saying "PHP Fatal error: Call to a member function live() on a non-object in ../test.php on line 24" I've searched the web for a while now and can't find a solution for this to work. Can someone help me with my poor understanding of php5?
__constructinstead ofNameOfTheClassin PHP5?