IMPRESS dotted_line CONTACT dotted_line search dotted_line Kontakt dotted_line sitemap dotted_line print
241 PHP-Resource users online

Switch to another languags Deutsch aktuelle Sprache Englisch

PHP Manual


(PHP 5 >= 5.4.0)

Closure::bind Duplicates a closure with a specific bound object and class scope


public static Closure Closure::bind ( Closure $closure , object $newthis [, mixed $newscope = 'static' ] )

This method is a static version of Closure::bindTo(). See the documentation of that method for more information.



The anonymous functions to bind.


The object to which the given anonymous function should be bound, or NULL for the closure to be unbound.


The class scope to which associate the closure is to be associated, or 'static' to keep the current one. If an object is given, the type of the object will be used instead. This determines the visibility of protected and private methods of the bound object.

Return Values

Returns a new Closure object or FALSE on failure


Example #1 Closure::bind() example

class {
    private static 
$sfoo 1;
$ifoo 2;
$cl1 = static function() {
$cl2 = function() {

$bcl1 Closure::bind($cl1null'A');
$bcl2 Closure::bind($cl2, new A(), 'A');
$bcl1(), "\n";
$bcl2(), "\n";

The above example will output something similar to:


See Also

Comments to the PHP manual
Write new comment


New Tutorial entries

Migration einer PHP 5 App auf PHP 7

Dieses PHP 7 Tutorial zeigt dir, wie du dein PHP5 Script auf PHP7 umstellst.

Berni | Category: PHP
PHP 7 Virtual Machine

Dieser Artikel zielt darauf ab, einen Überblick über die Zend Virtual Machine, wie es in PHP 7 gefunden wird.

Berni | Category: PHP
plotting masters - a professional guide - Teil II

Grafische Interpolation und Bestapproximation von numerischen Wertepaaren: Wir wollen Punkte auf einer Zeichenebene über verschiedene Verfahren miteinander verbinden.

EVAMasters | Category: PHP