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'); parent::bar(); } } (new Derp())->foo();
based on drmV1
Output for 7.0.0 - 7.2.0
string(8) "in class" Fatal error: Uncaught Error: Cannot access parent:: when current class scope has no parent in /in/i8OoZ:17 Stack trace: #0 /in/i8OoZ(5): Derp->bar() #1 /in/i8OoZ(20): Derp->foo() #2 {main} thrown in /in/i8OoZ on line 17
Process exited with code 255.
Output for 5.4.2 - 5.6.28
string(8) "in class" Fatal error: Cannot access parent:: when current class scope has no parent in /in/i8OoZ on line 17
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/i8OoZ on line 3
Process exited with code 255.