3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait Behaviors { public function __get($p) { if (method_exists($this, '__netteObjectFoo')) { $this->__netteObjectFoo($p); } if (method_exists($this, '__netteObjectBar')) { $this->__netteObjectBar($p); } } } trait Foo { public function __netteObjectFoo($p) { echo "foo"; } } trait Bar { public function __netteObjectBar($p) { echo "bar"; } } class A { use Behaviors, Foo; } class B { use Behaviors, Bar; } class C { use Behaviors, Foo, Bar; } (new A())->x; echo PHP_EOL; (new B())->x; echo PHP_EOL; (new C())->x; echo PHP_EOL;
based on 0TXTW
Output for 5.5.0 - 7.2.0
foo bar foobar