3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function autocreate($classname) { if (substr($classname, -strlen('Exception')) == 'Exception') eval('class ' . $classname . ' extends Exception {};'); } spl_autoload_register('autocreate'); $x = new TestException(); var_dump(get_class($x)); namespace Foo; $x = new Foo\TestException(); var_dump(get_class($x));
Output for 5.3.0 - 5.4.11
Fatal error: Namespace declaration statement has to be the very first statement in the script in /in/Q0MTK on line 16
Process exited with code 255.