3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $map = new Map(["a" => 1, "b" => 2]); $b = new ArrayIterator($dict); print var_dump($b); class A { public $x; public $y; public function __construct($x, $y) { $this->x = $x; $this->y = $y; } } $a = new A(1, "42"); print var_dump((new ArrayObject($a))->getIterator()); print "obj\n"; foreach ($a as $v) { $a->y = "500"; print $v . "\n"; } print "arr\n"; $b = array(1, 2, 3); foreach($b as $v) { $b[1] = 500; print $v . "\n"; } print "arr_iter\n"; $c = array(1, 2, 3); $i = new ArrayIterator($c); $i->rewind(); while ($i->valid()) { $c[1] = 500; print $i->current() . "\n"; $i->next(); }
based on dbViY
Output for 7.0.0 - 7.3.0beta1
Fatal error: Uncaught Error: Class 'Map' not found in /in/SrM6V:3 Stack trace: #0 {main} thrown in /in/SrM6V on line 3
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Class undefined: Map in /in/SrM6V:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: Class undefined: Map in /in/SrM6V:3 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Class 'Map' not found in /in/SrM6V on line 3
Process exited with code 255.