3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types = 1); class x { function __toString() : string { return "abc"; } } $x = new x; print $x . " and $x\n"; print $x; echo $x; echo PHP_EOL; print implode(', ', [$x, $x]); print implode($x, [1, 2]); ?>
Output for 8.4.1 - 8.4.21, 8.5.0 - 8.5.6
abc and abc abcabc abc, abc Fatal error: Uncaught TypeError: implode(): Argument #1 ($separator) must be of type string, x given in /in/R6XVR:17 Stack trace: #0 /in/R6XVR(17): implode(Object(x), Array) #1 {main} thrown in /in/R6XVR on line 17
Process exited with code 255.
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
abc and abc abcabc abc, abc Fatal error: Uncaught TypeError: implode(): Argument #1 ($separator) must be of type array|string, x given in /in/R6XVR:17 Stack trace: #0 /in/R6XVR(17): implode(Object(x), Array) #1 {main} thrown in /in/R6XVR on line 17
Process exited with code 255.

preferences:
73.31 ms | 1027 KiB | 5 Q