Created
August 20, 2009 14:26
-
-
Save infynyxx/171092 to your computer and use it in GitHub Desktop.
lambda in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$lambda = function($time) { | |
echo "I am an anonymous function and being called {$times} times<br/>"; | |
}; | |
function nCallTo($n, Closure $function) { | |
for ($i = 0; $i < $n; $i++) { | |
$function($i+1); | |
} | |
return function() { | |
echo "ending..."; | |
}; | |
} | |
$callBack = nCallTo(5, $lambda); | |
$callBack(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment