3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php use B\D, C\E as F; namespace A ; use B\D, C\E as F; // function calls function foo() { echo __NAMESPACE__;} namespace C; use B\D, C\E as F; declare(ticks=1); function tick_handler() { echo "tick_handler() called\n"; } class E { function foo() { echo __NAMESPACE__;}} //* namespace{ use B\D, C\E as F; // function calls*tick_handler()/ new E(); tick_handler(); E:foo(); // first tries to call "foo" defined in namespace "A" // then calls global function "foo" new D(); // using import rules, creates object of class "D" defined in namespace "B" // if not found, it tries to autoload class "B\D" new F(); // using import rules, creates object of class "E" defined in namespace "C" // if not found, it tries to autoload class "C\E" new \B(); // creates object of class "B" defined in global scope // if not found, it tries to autoload class "B" new \D(); // creates object of class "D" defined in global scope // if not found, it tries to autoload class "D" new \F(); // creates object of class "F" defined in global scope // if no ?>
Output for 7.0.0 - 7.1.0
tick_handler() called Fatal error: Uncaught Error: Call to undefined function C\foo() in /in/UPn2m:28 Stack trace: #0 {main} thrown in /in/UPn2m on line 28
Process exited with code 255.
Output for hhvm-3.12.0
tick_handler() called Fatal error: Uncaught Error: Call to undefined function C\foo() in /in/UPn2m:28 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.3.0 - 5.6.28, hhvm-3.10.0
tick_handler() called Fatal error: Call to undefined function C\foo() in /in/UPn2m on line 28
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /in/UPn2m on line 2
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, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /in/UPn2m on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_CONSTANT_ENCAPSED_STRING' or `'('' in /in/UPn2m on line 2
Process exited with code 255.