Skip to Content
PHPCODE
Handling Conflicts in Traits
oops code / August 12, 2018
<?php
trait one {
public function test()
{
echo “TEST method from one Trait”;
}
}
trait two {
public function test()
{
echo “TEST method from two Trait”;
}
}
class abc {
use one,two{
//insteadof
two::test insteadof one;
one::test as OneTest;
}
}
$obj=new abc;
echo $obj->OneTest();
?>
PHPCODE © 2023