I am learning Classes and Objects of PHP, but these codes confuses me:
<?php
class A
{
public function test()
{
//output will be A load(), why?
self::load();
//output will be B load(), why?
$this->load();
}
public function load()
{
echo "A load()";
}
}
class B extends A
{
public function test()
{
parent::test();
}
public function load()
{
echo "B load()";
}
}
$c = new B();
$c->test();
In these situation, why self::load()
and $this->load()
get different output?
Please describe with detail.