3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $test = function($p = 'abcde', $c = 'abc') { return substr($p, 0, strlen($c)) == $c; }; $test1 = function($p = 'abcde', $c = 'abc') { return strncmp($p, $c, strlen($c)); }; $print = function($closure, $s, $cycles = 10000000) { for ($i =0; $i < $cycles; $i++) { $closure(); } echo printf('Runns: %01.2f', microtime(1) - $s); echo PHP_EOL; }; $print($test, microtime(1)); $print($test1, microtime(1));
Output for 7.1.0
Runns: 0.8811 Runns: 1.1811
Output for 7.0.14
Runns: -0.6412 Runns: 2.7911
Output for 7.0.6
Runns: 0.8111 Runns: 0.9611
Output for 7.0.5
Runns: 0.8411 Runns: 0.9811
Output for 7.0.4
Runns: 0.7911 Runns: 0.9911
Output for 7.0.3
Runns: 0.8311 Runns: 0.9711
Output for 7.0.2
Runns: 0.8111 Runns: 0.9111
Output for 7.0.1
Runns: 0.8311 Runns: 0.9411
Output for 7.0.0
Runns: 0.8511 Runns: 0.9211
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0

Process exited with code 137.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/nSGcX on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/nSGcX on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/nSGcX on line 3
Process exited with code 255.