3v4l.org

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