Skip to content

Instantly share code, notes, and snippets.

@infynyxx
Created August 20, 2009 14:26
Show Gist options
  • Save infynyxx/171092 to your computer and use it in GitHub Desktop.
Save infynyxx/171092 to your computer and use it in GitHub Desktop.
lambda in PHP
<?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