一个匿名函数内要获取外部的变量必须要使用use:

$message = 'hello';
$example = function() use ($message){
  var_dump($message);
};
echo $example();
//输出hello

详见

http://www.jb51.net/article/79350.htm

相关文章:

  • 2021-05-22
  • 2021-04-30
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
  • 2022-02-03
  • 2021-10-05
猜你喜欢
  • 2021-07-01
  • 2022-02-20
  • 2022-12-23
  • 2021-10-23
  • 2021-07-29
  • 2021-07-17
相关资源
相似解决方案