3v4l.org

run code in 300+ PHP versions simultaneously
<?php $map = new WeakMap; $obj = new stdClass; $map[$obj] = 42; var_dump($map);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
object(WeakMap)#1 (1) { [0]=> array(2) { ["key"]=> object(stdClass)#2 (0) { } ["value"]=> int(42) } }
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Class 'WeakMap' not found in /in/o6lZX:3 Stack trace: #0 {main} thrown in /in/o6lZX on line 3
Process exited with code 255.

preferences:
52.06 ms | 407 KiB | 5 Q