Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP Closure::call()

PHP Closure::call()

PHP 7 New Features PHP 7 New Features

PHP 7's Closure::call() has better performance, dynamically binding a closure function to a new object instance and invoking that function.

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:



1

1


PHP 7 New Features PHP 7 New Features