3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $classmap1 = array(); for ($i=1; $i<=100; $i++) { $classmap1['a'.$i] = $i+1; } $classmap2 = array(); for ($i=1; $i<=100; $i++) { $classmap2['b'.$i] = $i+1; } $startTimeMerge = microtime(true); $map = array_merge($classmap1, $classmap2); $endTimeMerge = microtime(true); $startTimeForeach = microtime(true); foreach ($classmap2 as $k => $v) { $classmap1[$k] = $v; } $endTimeForeach = microtime(true); abstract class merging { public static function amerge(array &$a, array &$b) { foreach ($b as $key => $value) { $a[$key] = $value; } return $a; } } $startTimeFunc = microtime(true); merging:amerge($classmap1, $classmap2); $endTimeFunc = microtime(true); echo "Merging took " . (($endTimeMerge - $startTimeMerge)*1000) ." microseconds<br />\n"; //var_dump($map); echo "Foreach took " . (($endTimeForeach - $startTimeForeach)*1000) ." microseconds<br />\n"; //var_dump($classmap1); echo "Func took " . (($endTimeFunc - $startTimeFunc)*1000) ." microseconds<br />\n"; //var_dump($am);
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function amerge() in /in/1laVd:38 Stack trace: #0 {main} thrown in /in/1laVd on line 38
Process exited with code 255.
Output for 5.3.0 - 5.6.21, hhvm-3.10.0 - 3.12.0
Fatal error: Call to undefined function amerge() in /in/1laVd on line 38
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected ':' in /in/1laVd on line 38
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/1laVd on line 27
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/1laVd on line 26
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CLASS in /in/1laVd on line 26
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/1laVd on line 26
Process exited with code 255.