简单的例子(使用(){}在writecodeonline运行时不工作
问题描述:
我得到简单的例子(使用(){}在<a href="http://www.writephponline.com/" rel="nofollow">writecodeonline</a>运行时不工作
语法错误,意想不到的 '使用'(T_USE),预计 '{' 上线4
$x = "Hi guys";
function foo() use($x) {
echo $x;
}
foo();
答
我可能会误解,但我只看到了use
匿名函数。尝试类似这样的
$x = "Hi guys";
$theFunction = function() use ($x) {
echo $x;
};
$theFunction();
答
它应该是:
$x = "Hi guys";
$foo= function() use ($x) {
echo $x;
};
$foo();
是不是'匿名'功能使用? – lascort
是的@lascort,是的:-) – AbraCadaver
http://php.net/manual/en/functions.anonymous.php – AbraCadaver