3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait Herp { function foo() { $this->bar(); } function bar() { var_dump('in trait'); } } class Derp { use Herp; function bar() { var_dump('in class'); Herp::bar(); } } (new Derp())->foo();
based on i8OoZ
Output for 7.0.0 - 7.2.0
string(8) "in class" Deprecated: Non-static method Herp::bar() should not be called statically in /in/ODZCF on line 17 string(8) "in trait"
Output for 5.6.7 - 5.6.28
string(8) "in class" Deprecated: Non-static method Herp::bar() should not be called statically, assuming $this from incompatible context in /in/ODZCF on line 17 string(8) "in trait"
Output for 5.4.2 - 5.5.35
string(8) "in class" Strict Standards: Non-static method Herp::bar() should not be called statically, assuming $this from incompatible context in /in/ODZCF on line 17 string(8) "in trait"
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/ODZCF on line 3
Process exited with code 255.