Closure { /* 方法 */ __construct ( void ) //用于禁止实例化的构造函数 public static Closure bind ( Closure $closure , object $newthis [, mixed $newscope = 'static' ] ) //复制一个闭包,绑定指定的$this对象和类作用域。 public Closure bindTo ( object $newthis [, mixed $newscope = 'static' ] ) //复制当前闭包对象,绑定指定的$this对象和类作用域。 }
class A {
private static $sfoo = 1 ;
private $ifoo = 2 ;
}
$cl1 = static function() {
return A :: $sfoo ;
};
$cl2 = function() {
return $this -> ifoo ;
};
$bcl1 = Closure :: bind ( $cl1 , null , 'A' );
$bcl2 = Closure :: bind ( $cl2 , new A (), 'A' );
echo $bcl1 (), "\n" ;
echo $bcl2 (), "\n" ;
您可能感兴趣的文章: