3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function test1() { $str = 'derp'; if ($str != 'files' && $str != 'something' && $str != 'Derrr') { return; } return; } function test2() { $str = 'derp'; switch ($str) { case 'files': case 'something': case 'Derrr': break; default: return; } return; } function runTest1() { $start1 = microtime(1); for ($i = 1; $i < 10000; $i++) { test1(); } $start1 -= microtime(1); return $start1; } function runTest2() { $start2 = microtime(1); for ($i = 1; $i < 10000; $i++) { test2(); } $start2 -= microtime(1); return $start2; } $tests2 = 0; for($i = 0;$i<1000;$i++) { $tests2 += runTests2(); } $start2 = $tests2 / 1000; $tests1 = 0; for($i = 0;$i<1000;$i++) { $tests1 += runTests2(); } $start2 = $tests1 / 1000; if ($start1 < $start2) { $perc = 100-round(($start2 / $start1) * 100,2); echo "Test1 is $perc"."% faster than Test2"; } if ($start2 < $start1) { $perc = 100-round(($start1 / $start2) * 100,2); echo "Test2 is $perc"."% faster than Test1"; }
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function runTests2() in /in/4gHtI:46 Stack trace: #0 {main} thrown in /in/4gHtI on line 46
Process exited with code 255.
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0
Fatal error: Call to undefined function runTests2() in /in/4gHtI on line 46
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: runtests2() in /in/4gHtI on line 46
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: runtests2() in /in/4gHtI on line 46
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: runtests2() in /in/4gHtI on line 46