Answer the question
In order to leave comments, you need to log in
How to use trait in child class?
Hello!
There is a code:
trait SomeTrait
{
public function someMethod() { echo 'Running trait method', PHP_EOL; }
}
class Foo
{
use SomeTrait;
}
class Child extends Foo
{
public function someMethod2() {
echo 'Running class method', PHP_EOL;
parent::someOtherMethod();
}
}
$ch = new Child;
$ch->someMethod2();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question