使用关键字use使用外部变量
$c = 4343; $func1 = function ($a,$b) use($c) { $c = 555; var_dump($c); }; $func1(1,2); var_dump($c);
php闭包