3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = new class { function __toString() { return "_"; } }; var_dump(implode($a, ["a", "b"])); var_dump(implode(["a", "b"], $a));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
string(3) "a_b" Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, class@anonymous given in /in/4FWBj:8 Stack trace: #0 /in/4FWBj(8): implode(Array, Object(class@anonymous)) #1 {main} thrown in /in/4FWBj on line 8
Process exited with code 255.
Output for 7.4.0 - 7.4.33
string(3) "a_b" Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/4FWBj on line 8 string(3) "a_b"
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
string(3) "a_b" string(3) "a_b"
Output for 5.6.0 - 5.6.27
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/4FWBj on line 3
Process exited with code 255.

preferences:
231.26 ms | 401 KiB | 207 Q