Lambda Functions, Closures, and __invoke
Posted on April 26th, 2009 by SamPreviously, lambda-style functions were only possible by using create_function. This has one major disadvantage, the function is compiled at run time, opcode caches can’t cache the function at compile time.
<?php
$func = create_function(’$a,$b’, ‘return "ln($a) + ln($b) = " . log($a * $b);’);
echo "New anonymous function: $func\n";
echo $newfunc(2, M_E) . "\n";
// New anonymous function: lambda_1
// [...]




![Validate my RSS feed [Valid RSS]](http://php-phreaks.com/wp-content/themes/php-Phreaks/imgs/valid-rss.png)