Everyone knows that function calls in PHP hit the performance badly. This script demonstats the problem:
// Plain variable assignment.
$time = microtime(true);
$i = 100000;
while ($i--)
{
$x = 'a';
}
echo microtime(true) - $time."\n\n";
// 0.017973899841309
$time = microtime(true);
function f() { $a = "a"; return $a; }
$i = 100000;
while ($i--)
{
$x = f();
}
echo microtime(true) - $time."\n\n";
//0.18558096885681
By the way anonymous functions are the worst. thy are 10 times slower.
Is there a PHP-Script-Optimizer that reduces the amount of function calls and minifies the script?
There is also this post: Why are PHP function calls *so* expensive? related to this article