3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fp = $fp = fopen(__FILE__, "r"); class classA { public function __toString() { return "Class A object"; } } $a = array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'); var_dump($a); var_dump(array_combine($a, $a));
Output for 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: Cannot access offset of type classA on array in /in/CdYaE:8 Stack trace: #0 {main} thrown in /in/CdYaE on line 8
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Fatal error: Uncaught TypeError: Illegal offset type in /in/CdYaE:8 Stack trace: #0 {main} thrown in /in/CdYaE on line 8
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Illegal offset type in /in/CdYaE on line 8 Notice: Resource ID#5 used as offset, casting to integer (5) in /in/CdYaE on line 8 array(2) { [""]=> string(5) "hello" [5]=> string(8) "resource" } array(2) { ["hello"]=> string(5) "hello" ["resource"]=> string(8) "resource" }
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Warning: Illegal offset type in /in/CdYaE on line 8 Warning: Illegal offset type in /in/CdYaE on line 8 array(1) { [""]=> string(5) "hello" } array(1) { ["hello"]=> string(5) "hello" }

preferences:
216.64 ms | 403 KiB | 333 Q