3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X { function __toString() { return array(1,2,3); } } $x = new X; echo $x;
Output for 8.0.0 - 8.0.13, 8.1rc1 - rc3
Fatal error: Uncaught TypeError: X::__toString(): Return value must be of type string, array returned in /in/gZT8v:5 Stack trace: #0 /in/gZT8v(10): X->__toString() #1 {main} thrown in /in/gZT8v on line 5
Process exited with code 255.
Output for 7.4.0 - 7.4.26
Fatal error: Uncaught Error: Method X::__toString() must return a string value in /in/gZT8v:10 Stack trace: #0 {main} thrown in /in/gZT8v on line 10
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.12 - 7.3.33
Recoverable fatal error: Method X::__toString() must return a string value in /in/gZT8v on line 10
Process exited with code 255.
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20
Catchable fatal error: Method X::__toString() must return a string value in /in/gZT8v on line 10
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Method X::__toString() must return a string value in /in/gZT8v on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
Object

preferences:
42.8 ms | 466 KiB | 5 Q