3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace foo { trait A { function x() { var_dump(self::class); } } class Q { use \foo\A; } class R extends Q {} } namespace { class B { use \foo\A; } class C { use \foo\A; } class D extends C {} function main() { (new B)->x(); (new C)->x(); (new D)->x(); (new Q)->x(); (new R)->x(); } main(); }
based on 3vhT9
Output for 7.0.0 - 7.2.0
string(1) "B" string(1) "C" string(1) "C" Fatal error: Uncaught Error: Class 'Q' not found in /in/boZBh:18 Stack trace: #0 /in/boZBh(22): main() #1 {main} thrown in /in/boZBh on line 18
Process exited with code 255.
Output for 5.5.24 - 5.6.28
string(1) "B" string(1) "C" string(1) "C" Fatal error: Class 'Q' not found in /in/boZBh on line 18
Process exited with code 255.
Output for 5.4.10 - 5.4.45
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/boZBh on line 4
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/boZBh on line 4
Process exited with code 255.