Skip to content

Instantly share code, notes, and snippets.

@filhodanuvem
Created May 29, 2012 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filhodanuvem/2828702 to your computer and use it in GitHub Desktop.
Save filhodanuvem/2828702 to your computer and use it in GitHub Desktop.
PHP não tem closure?
<?php
$lambda = function() use($nota){
echo '<br />'.$nota;
};
function soma($v1,$v2,$f){
$nota = $v1 + $v2 ;
$f();
}
soma(1,2,$lambda);
@jeanpimentel
Copy link

$lambda = function($nota) {
   var_dump($nota);
};

function soma($v1, $v2, $f) {
   $nota = $v1 + $v2;
   echo $f($nota);
}

soma(1, 2, $lambda);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment