Hello
I thought php could inherit from a main class. Some way the variable in the subclass seems to be empty.
<?php
class Animals
{
var $Legs;
function Animals()
{
$this->Legs = 4;
}
}
class Dogs extends Animals
{
function Dogs()
{
}
}
$data = new Animals;
$data->Legs = 8;
$Dog = new Dogs;
$Number = $Dog->Legs;
echo"Legs: $Number\n";
?>
Can someone explain to me why i can't inherit a variable from the main class? I know it can be done by define(), but is there another possibility?