PHP7新特性--Closure::call()
<?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());
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »