3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = new \stdClass(); $a->rec = $a; print_r($a); var_dump($a); $a = new class() { public function __toString(): string { static $c = 0; if ($c++ > 1) { throw new \Exception('ex'); } return '1'; } }; echo $a, $a, $a;
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
stdClass Object ( [rec] => stdClass Object *RECURSION* ) object(stdClass)#1 (1) { ["rec"]=> *RECURSION* } 11 Fatal error: Uncaught Exception: ex in /in/DWqcW:13 Stack trace: #0 /in/DWqcW(20): class@anonymous->__toString() #1 {main} thrown in /in/DWqcW on line 13
Process exited with code 255.

preferences:
137.16 ms | 407 KiB | 5 Q