关于Closure :: bind的PHP文档中的示例包括匿名函数声明中的static.为什么?如果删除它,我找不到区别.
有:
class A { private static $sfoo = 1; } $cl1 = static function() { return self::$sfoo; }; // notice the "static" $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,'A'); echo $bcl1(); // output: 1