$parent , .
, , , , .
PHP , ( ), , . $this , , .
To create $parent, you will need to place the object inside $parent. You are not technically created a parent class, so it cannot be assigned to a variable.
BTW parent::function();has access to everyone $this.
Hence it works
class Test
{
public function test()
{
echo $this->testing_var;
}
}
class OtherTest
{
public function run()
{
$this->testing_var = "hi";
Test::test();
}
}
And it will be a mistake if it is used outside the class and tells you that it should be declared static.
Test::test();
source
share