3v4l.org

run code in 300+ PHP versions simultaneously
<?php function setPrevious(Throwable $e, Throwable $previous): Throwable { return (function () use ($e, $previous) { $e->previous = $previous; return $e; })->call($e); } class SimpleException extends Exception { public function __construct($message) { parent::__construct($message); } } $a = new SimpleException('A'); $b = new SimpleException('B'); $c = new SimpleException('C'); setPrevious($a, $b); setPrevious($a, $c); $e = $a; do { var_dump($e->getMessage()); } while ($e = $e->getPrevious());
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property SimpleException::$previous is deprecated in /in/4scuq on line 6 string(1) "A"

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