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 151 views
3 answers 272 views
1 answer 103 views
1 answer 231 views
2 answers 181 views
...