3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $x = new class() { public $callCounters = []; public function call($index) { $this->callCounters[$index] ?? 0; ++$this->callCounters[$index]; } }; $indexes = range('a','e'); foreach($indexes as $index) { $r = rand(1,4); for($i = 0; $i <= $r; ++$i) { $x->call($index); } } var_dump($x->callCounters);
based on oETLW
Output for 7.2.6
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(2) ["b"]=> int(3) ["c"]=> int(5) ["d"]=> int(2) ["e"]=> int(4) }
Output for 7.2.0
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(2) ["b"]=> int(2) ["c"]=> int(5) ["d"]=> int(4) ["e"]=> int(3) }
Output for 7.1.10
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(4) ["b"]=> int(2) ["c"]=> int(2) ["d"]=> int(4) ["e"]=> int(4) }
Output for 7.1.7
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(5) ["b"]=> int(5) ["c"]=> int(3) ["d"]=> int(3) ["e"]=> int(3) }
Output for 7.1.6
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(5) ["b"]=> int(3) ["c"]=> int(2) ["d"]=> int(4) ["e"]=> int(3) }
Output for 7.1.5
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(2) ["b"]=> int(5) ["c"]=> int(4) ["d"]=> int(5) ["e"]=> int(3) }
Output for 7.1.4
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(5) ["b"]=> int(3) ["c"]=> int(3) ["d"]=> int(2) ["e"]=> int(4) }
Output for 7.1.3
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(5) ["b"]=> int(2) ["c"]=> int(4) ["d"]=> int(2) ["e"]=> int(3) }
Output for 7.1.2
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(4) ["b"]=> int(4) ["c"]=> int(3) ["d"]=> int(3) ["e"]=> int(5) }
Output for 7.1.1
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(2) ["b"]=> int(5) ["c"]=> int(4) ["d"]=> int(2) ["e"]=> int(3) }
Output for 7.1.0
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(5) ["b"]=> int(3) ["c"]=> int(3) ["d"]=> int(2) ["e"]=> int(2) }
Output for 7.0.20
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(4) ["b"]=> int(3) ["c"]=> int(2) ["d"]=> int(4) ["e"]=> int(3) }
Output for 7.0.19
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(4) ["b"]=> int(3) ["c"]=> int(2) ["d"]=> int(2) ["e"]=> int(4) }
Output for 7.0.18
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(4) ["b"]=> int(3) ["c"]=> int(3) ["d"]=> int(5) ["e"]=> int(4) }
Output for 7.0.17
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(4) ["b"]=> int(2) ["c"]=> int(2) ["d"]=> int(2) ["e"]=> int(5) }
Output for 7.0.16
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(5) ["b"]=> int(5) ["c"]=> int(5) ["d"]=> int(2) ["e"]=> int(5) }
Output for 7.0.15
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(3) ["b"]=> int(5) ["c"]=> int(4) ["d"]=> int(3) ["e"]=> int(3) }
Output for 7.0.14
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(4) ["b"]=> int(2) ["c"]=> int(2) ["d"]=> int(5) ["e"]=> int(2) }
Output for 7.0.13
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(5) ["b"]=> int(4) ["c"]=> int(5) ["d"]=> int(2) ["e"]=> int(4) }
Output for 7.0.12
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(2) ["b"]=> int(3) ["c"]=> int(4) ["d"]=> int(5) ["e"]=> int(5) }
Output for 7.0.11
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(4) ["b"]=> int(4) ["c"]=> int(3) ["d"]=> int(3) ["e"]=> int(2) }
Output for 7.0.10
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(4) ["b"]=> int(5) ["c"]=> int(5) ["d"]=> int(5) ["e"]=> int(2) }
Output for 7.0.9
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(2) ["b"]=> int(3) ["c"]=> int(5) ["d"]=> int(4) ["e"]=> int(4) }
Output for 7.0.8
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(2) ["b"]=> int(3) ["c"]=> int(4) ["d"]=> int(2) ["e"]=> int(2) }
Output for 7.0.7
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(3) ["b"]=> int(3) ["c"]=> int(3) ["d"]=> int(5) ["e"]=> int(2) }
Output for 7.0.6
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(3) ["b"]=> int(3) ["c"]=> int(2) ["d"]=> int(5) ["e"]=> int(2) }
Output for 7.0.5
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(2) ["b"]=> int(4) ["c"]=> int(5) ["d"]=> int(5) ["e"]=> int(5) }
Output for 7.0.4
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(5) ["b"]=> int(2) ["c"]=> int(5) ["d"]=> int(2) ["e"]=> int(4) }
Output for 7.0.3
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(4) ["b"]=> int(5) ["c"]=> int(3) ["d"]=> int(5) ["e"]=> int(3) }
Output for 7.0.2
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(3) ["b"]=> int(2) ["c"]=> int(5) ["d"]=> int(4) ["e"]=> int(3) }
Output for 7.0.1
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(5) ["b"]=> int(2) ["c"]=> int(3) ["d"]=> int(4) ["e"]=> int(3) }
Output for 7.0.0
Notice: Undefined index: a in /in/jMb5Y on line 7 Notice: Undefined index: b in /in/jMb5Y on line 7 Notice: Undefined index: c in /in/jMb5Y on line 7 Notice: Undefined index: d in /in/jMb5Y on line 7 Notice: Undefined index: e in /in/jMb5Y on line 7 array(5) { ["a"]=> int(3) ["b"]=> int(4) ["c"]=> int(2) ["d"]=> int(3) ["e"]=> int(3) }
Output for hhvm-3.15.4
array(5) { ["a"]=> int(2) ["b"]=> int(4) ["c"]=> int(4) ["d"]=> int(2) ["e"]=> int(4) }
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/jMb5Y on line 3
Process exited with code 255.