【发布时间】:2013-11-22 20:21:35
【问题描述】:
Closure::bind 的 php 文档中的示例在匿名函数声明中包含 static。为什么?去掉的话我就找不到区别了。
与:
class A {
private static $sfoo = 1;
}
$cl1 = static function() { // notice the "static"
return self::$sfoo;
};
$bcl1 = Closure::bind($cl1, null, 'A');
echo $bcl1(); // output: 1
没有:
class A {
private static $sfoo = 1;
}
$cl1 = function() {
return self::$sfoo;
};
$bcl1 = Closure::bind($cl1, null, 'A');
echo $bcl1(); // output: 1
【问题讨论】: