Closure::call

(PHP 7, PHP 8)

Closure::callBinds and calls the closure

Beschreibung

public Closure::call(object $newThis, mixed ...$args): mixed

Temporarily binds the closure to newThis, and calls it with any given parameters.

Parameter-Liste

newThis

The object to bind the closure to for the duration of the call.

args

Zero or more parameters, which will be given as parameters to the closure.

Rückgabewerte

Returns the return value of the closure.

Beispiele

Beispiel #1 Closure::call() example

<?php
class Value {
    protected 
$value;

    public function 
__construct($value) {
        
$this->value $value;
    }

    public function 
getValue() {
        return 
$this->value;
    }
}

$three = new Value(3);
$four = new Value(4);

$closure = function ($delta) { var_dump($this->getValue() + $delta); };
$closure->call($three4);
$closure->call($four4);
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

int(7)
int(8)

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

PHPMailer Umlaute Probleme

Ah, das ist ein klassisches Thema: Umlaute (ä, ö, ü, ß) und PHPMailer. Probleme entstehen oft, wenn Zeichencodierung oder Header nicht korrekt ...

Geschrieben von smashkarts am 04.09.2025 07:16:16
Forum: PHP Developer Forum
[Wichtig] Anmeldung im Forum

Geometry Dash has become a renowned name in the world of fast-paced platformer games, capturing the hearts of gamers across the globe. This colorf ...

Geschrieben von fangfitaeraki am 04.09.2025 05:28:36
Forum: Fragen/Vorschläge zum Forum
Why Geometry Dash Remains Timeless

Geometry Dash: A Comprehensive Guide to the Rhythm-Based Platformer Caption: Geometry Dash Image at the Beginning – Jump into the rhythm-bas ...

Geschrieben von fangfitaeraki am 04.09.2025 05:21:51
Forum: Ankündigungen
Probleme mit speichern in Datenbank in französisch

It sounds like you're facing encoding issues when inserting data, especially French text with apostrophes. This is a common problem, kind of like ...

Geschrieben von Rodriguezin89 am 04.09.2025 04:58:20
Forum: PHP Developer Forum