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.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.6
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.30
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:
32.72 ms | 861 KiB | 4 Q