YouTip LogoYouTip

Php Closure Call

# PHP Closure::call() [![Image 3: PHP 7 New Features](#) PHP 7 New Features](#) PHP 7's Closure::call() offers better performance, dynamically binding a closure function to a new object instance and invoking it. ### Example ## Example x; }; // Closure function bound to class A $getX = $getXCB->bindTo(new A, 'A'); echo $getX(); print(PHP_EOL); // PHP 7+ code $getX = function() { return $this->x; }; echo $getX->call(new A); ?> The output of the above program is: 11 * * PHP 7 New Features](#)
← Php Closure CallPhp Constant Arrays β†’