3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php declare(ticks=1) function tick_handler() { echo "tick_handler() called\n"; } use B\D, C\E as F; namespace A ; use B\D, C\E as F; // function calls function foo() { echo __NAMESPACE__;} namespace B; use B\D, C\E as F; class D { function foo() { echo __NAMESPACE__;}} //* namespace{ use B\D, C\E as F; echo __NAMESPACE__; // function calls*tick_handler()/ new D(); tick_handler(); echo __NAMESPACE__; D: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 5.4.0 - 5.4.19
Parse error: syntax error, unexpected 'tick_handler' (T_STRING), expecting '(' in /in/aZUYf on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_STRING, expecting '(' in /in/aZUYf on line 3
Process exited with code 255.