<?php
//Closure::call() 现在有着更好的性能,简短干练的暂时绑定一个方法到对象上闭包并调用它。
// 声明一个class A
class A
{

    private $x = "1";

    public function testEcho()
    {
        echo "!!!";
    }
}

// 创建一个匿名函数

$getX = function () {
    
    $this->testEcho();
    return $this->x;
};

echo $getX->call(new A());
最后修改:2019 年 09 月 05 日
如果觉得我的文章对你有用,请随意赞赏