3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * driver.php * ---------- * Registers a shutdown-function, that includes "error_handler.php" (which merely defines * a innocuous function named "handle_error", and includes "throw_fatal_error.php" * (that provokes an error declaring two classes with the same name). * * What happens is that the fatal error is thrown, shutdownFunc() is called and * "error_handler.php" is included -- but it occurs another fatal error, complaining that * handle_error() (defined in "error_handler.php") is undefined. * The problem does not happen with classes, as can be demonstrated by ErrorClass, * which is defined in "error_handler.php" and it's existence checked on shutdownFunc(). * * VERY IMPORTANT NOTE * If "throw_fatal_error.php" does not include a namespace or if neither class inherits * from another, everything works ok! */ function shutdownFunc () { eval(<<<'PHP' function handle_error () { echo "handle_error() is here<br />\n"; } class ErrorClass extends \stdclass {} PHP ); echo "We're about to call <em>handle_error()</em>...<br />\n"; echo 'ErrorClass is ', class_exists ('ErrorClass') ? 'undefined' : 'defined', "<br />\n"; handle_error(); } register_shutdown_function ('shutdownFunc'); // Make sure errors are printed. ini_set ('display_errors', 'On'); // Include the file that provokes the error. eval(<<<'PHP' namespace test; class aclass {} class aclass extends \stdclass {} PHP );
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Cannot declare class test\aclass, because the name is already in use in /in/EsDVZ(40) : eval()'d code on line 5 We're about to call <em>handle_error()</em>...<br /> ErrorClass is undefined<br /> handle_error() is here<br />
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
46.18 ms | 401 KiB | 8 Q