W3cubDocs

/PHP

The Closure class

Introduction

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

Class used to represent anonymous functions.

Anonymous functions yield objects of this type. This class has methods that allow further control of the anonymous function after it has been created.

Besides the methods listed here, this class also has an __invoke method. This is for consistency with other classes that implement calling magic, as this method is not used for calling the function.

Class synopsis

Closure {
/* Methods */
private __construct ( )
public static bind ( Closure $closure , object $newthis [, mixed $newscope  = "static" ] ) : Closure|false
public bindTo ( object $newthis [, mixed $newscope  = "static" ] ) : Closure|false
public call ( object $newthis , mixed ...$values ) : mixed
public static fromCallable ( callable $callable ) : Closure
}

Table of Contents

© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/class.closure.php