- print_r: documentation ( source)
<?php
class B {
public function method()
{
echo "BBB";
}
}
class A
{
public function method()
{
echo "I'not suppose to";
}
}
class TestParentClass extends A
{
public function method()
{
print_r('Parent method');
print "\n";
}
}
trait TestTrait
{
public function method()
{
print_r('Trait method');
print "\n";
}
}
class TestChildClass extends TestParentClass
{
use TestTrait
{
A::method as mth;
/*
TestTrait::method as methodAlias;
TestParentClass::method insteadof TestTrait;
*/
}
}
(new TestChildClass)->mth();
(new TestChildClass)->method();
(new TestChildClass)->method();
(new TestChildClass)->methodAlias();