相关疑难解决方法(0)

php闭包:为什么绑定到静态类时匿名函数声明中的'static'?

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)

php closures bind

13
推荐指数
4
解决办法
6442
查看次数

标签 统计

bind ×1

closures ×1

php ×1