php【闭包语法】function() use ($arg) {}

时间:2016-12-16 14:22:05   收藏:0   阅读:236
$arg = ‘text‘;
$test = function () use ($arg){
 var_dump($arg);
};
$test();

//输出text

 

$arg = ‘text‘;
$test = function () use ($arg){
 var_dump($arg);
 $arg = ‘text2‘;
};
$test();  //输出text

$arg = ‘text3‘;
$test(); //输出text

 

原文:http://www.cnblogs.com/wy04313/p/6186465.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!