3v4l.org

run code in 300+ PHP versions simultaneously
<?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.3.21, 5.4.0 - 5.4.11
Fatal error: Namespace declaration statement has to be the very first statement in the script in SYJ4J on line 16
Process exited with code 255.

preferences:
174.53 ms | 1395 KiB | 41 Q