Method Overriding in Traits
oops code / August 12, 2018
<?php
class Base {
public function abc()
{
echo “ABC method from Base class.”;
}
}
trait Test {
public function abc()
{
echo “ABC method from test trait.”;
}
}
class Child extends Base {
use Test;
public function abc()
{
echo “ABC method from Child Class.”;
}
}
$obj=new Child;
$obj->abc();
?>
class Base {
public function abc()
{
echo “ABC method from Base class.”;
}
}
trait Test {
public function abc()
{
echo “ABC method from test trait.”;
}
}
class Child extends Base {
use Test;
public function abc()
{
echo “ABC method from Child Class.”;
}
}
$obj=new Child;
$obj->abc();
?>