3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { function __toString() { return 'A'; } } $a = new A(); $b = [$a => $a]; 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/4teSv:11 Stack trace: #0 {main} thrown in /in/4teSv 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/4teSv:11 Stack trace: #0 {main} thrown in /in/4teSv on line 11
Process exited with code 255.

preferences:
54.9 ms | 877 KiB | 4 Q