$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
php【闭包语法】function() use ($arg) {}
原文:http://www.cnblogs.com/wy04313/p/6186465.html