If I have this code, the string "test" is echoed. This is in PHP 5.3. Is this some oversight that shouldn't be relied on, or is it some way of achieving multiple inheritence in PHP?
class Test1
{
function getName()
{
return $this->name;
}
}
class Test2
{
public $name = 'test';
function getName()
{
return Test1::getName();
}
}
$test = new Test2;
echo $test->getName();
EDIT:
As has been pointed out the comments by GZipp this is actually documented behaviour. See this page: http://us2.php.net/manual/en/language.oop5.basic.php and the heading "Example #2 Some examples of the $this pseudo-variable".
Classes A and B have a similar relationship to my two test classes above and the lines
$b = new B();
$b->bar();
Show more or less the same result as my example.