3v4l.org

run code in 300+ PHP versions simultaneously
<?php $loop = 100000; $s = 'a'; $t = 'b'; function t($p1, $p2) { return $p1.$p1; } $f1 = function() use ($s, $t) { return $s.$t; }; $f2 = function($s, $t) { return $s.$t; }; $tmp = $loop; $start = microtime(true); while($tmp--) { $r = t($s, $t); } echo 'Function: '. (microtime(true) - $start). "\n\n"; $tmp = $loop; $start = microtime(true); while($tmp--) { $r = $f1(); } echo 'Closure(use): '. (microtime(true) - $start). "\n\n"; $tmp = $loop; $start = microtime(true); while($tmp--) { $r = $f2($s, $t); } echo 'Closure(param): '. (microtime(true) - $start). "\n\n";

preferences:
32.56 ms | 402 KiB | 5 Q