3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php trait HelloWorld { private function sayHello() { echo 'Hello World!'; } } // Change visibility of sayHello class MyClass1 { use HelloWorld { HelloWorld::sayHello insteadof MyClass1; } public function sayHello() { echo 'Get Lost'; } } $class = new MyClass1(); $class->sayHello();
Output for 7.0.0 - 7.1.0
Fatal error: Class MyClass1 is not a trait, Only traits may be used in 'as' and 'insteadof' statements in /in/n72jQ on line 10
Process exited with code 255.
Output for hhvm-3.12.0 - 3.13.2
Fatal error: Uncaught Error: Unknown trait 'MyClass1' in /in/n72jQ:10 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Fatal error: Unknown trait 'MyClass1' in /in/n72jQ on line 10
Process exited with code 255.
Output for 5.4.13 - 5.6.28
Fatal error: Class MyClass1 is not a trait, Only traits may be used in 'as' and 'insteadof' statements in /in/n72jQ on line 17
Process exited with code 255.
Output for 5.4.11 - 5.4.12
Fatal error: Trait MyClass1 is not used in /in/n72jQ on line 17
Process exited with code 255.
Output for 5.4.0 - 5.4.10
Get Lost
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/n72jQ on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/n72jQ on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/n72jQ on line 3
Process exited with code 255.