3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { function __toString() { return "A"; } } $a = new a; $b = [$a => $a]; //Illegal offset type print_r($b);
Output for 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
Fatal error: Uncaught TypeError: Cannot access offset of type A on array in /in/CfEaW:11 Stack trace: #0 {main} thrown in /in/CfEaW on line 11
Process exited with code 255.
Output for 8.1.34, 8.2.0 - 8.2.31
Fatal error: Uncaught TypeError: Illegal offset type in /in/CfEaW:11 Stack trace: #0 {main} thrown in /in/CfEaW on line 11
Process exited with code 255.

preferences:
55.77 ms | 877 KiB | 4 Q