闭包绑定bind/bindTo

绑定的对象决定了返回的闭包对象中的$this的取值,类作用域决定返回的闭包对象能够调用哪些方法,也就是说,此时$this可以调用的方法,与newscope类作用域相同。

newthis表示绑定给闭包对象的一个对象,或者NULL来取消绑定。

newscope表示关联到闭包对象的类作用域,可以传入类名或类的示例,默认值是 'static', 表示不改变。

Closure {
    __construct ( void )
    public static Closure bind (Closure $closure , object $newthis [, mixed $newscope = 'static' ])
    public Closure bindTo (object $newthis [, mixed $newscope = 'static' ])
}
https://blog.csdn.net/wuxing26jiayou/article/details/51067190

猜你喜欢

转载自blog.csdn.net/qq_37699037/article/details/82855123
今日推荐