| Home | Mirror | Search | ITEYE 博客 | OSChina 博客 | 51CTO 博客 |
闭包函数也可以作为变量的值来使用。
<?php
$put = function($name)
{
printf("%s\r\n", $name);
};
$put('World');
$put('PHP');
?>
<?php
$aaa = 111;
$func = function() use($aaa){ print $aaa; };
$aaa = 222;
$func(); // Outputs "111"
?>