php闭包:为什么在绑定到静态类时,匿名函数声明中的“static”?
php 文档中的示例 on include on the anonymous function 声明。为什么?如果它被删除,我找不到区别。Closure::bind
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