php文档中的示例Closure::bind包含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
Run Code Online (Sandbox Code Playgroud)
没有:
class A { private static $sfoo = 1; }
$cl1 = function() { return self::$sfoo; };
$bcl1 = Closure::bind($cl1, null, 'A');
echo $bcl1(); // output: 1
Run Code Online (Sandbox Code Playgroud)