How to use outside variable with anonymous function in PHP

1 Answer

0 votes
$b = 13;
$afunction = function($number) use ($b) {
    return $number * $b;
};

echo $afunction(736316); 
  
/*
run: 
 
9572108
   
*/

 



answered Sep 16, 2017 by avibootz

Related questions

1 answer 157 views
3 answers 282 views
1 answer 110 views
1 answer 235 views
2 answers 186 views
...