3v4l.org

run code in 300+ PHP versions simultaneously
<?php function previous_handler(Throwable $e) { printf("This is the PREVIOUS handler for %s\n", $e->getMessage()); } //------------ class Configurator { public static function setupPhpErrorListener(): void { $controller = new PhpErrorController(); $controller->usePreviousExceptionHandler(set_exception_handler([$controller, 'onException'])); } } class PhpErrorController { private $previous = null; public function usePreviousExceptionHandler(?callable $previous): void { $this->previous = $previous; } public function onException(Throwable $throwable): void { printf("This is the WONOLOG handler for %s\n", $throwable->getMessage()); if ($this->previous === null) { throw $throwable; } ($this->previous)($throwable); } } //------------ set_exception_handler('previous_handler'); Configurator::setupPhpErrorListener(); throw new Exception('Test exception');
Output for git.master_jit, git.master, rfc.property-hooks
This is the WONOLOG handler for Test exception This is the PREVIOUS handler for Test exception

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:
27.46 ms | 405 KiB | 5 Q