debug_zval_dump

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

debug_zval_dumpDumps a string representation of an internal zval structure to output

Beschreibung

debug_zval_dump(mixed $value, mixed ...$values): void

Dumps a string representation of an internal zval (Zend value) structure to output. This is mostly useful for understanding or debugging implementation details of the Zend Engine or PHP extensions.

Parameter-Liste

value

The variable or value to dump.

values

Further variables or values to dump.

Rückgabewerte

Es wird kein Wert zurückgegeben.

Beispiele

Beispiel #1 debug_zval_dump() example

<?php
$var1 
'Hello';
$var1 .= ' World';
$var2 $var1;

debug_zval_dump($var1);
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

string(11) "Hello World" refcount(3)

Hinweis: Understanding the refcount

The refcount value shown by this function may be surprising without a detailed understanding of the engine's implementation.

The Zend Engine uses reference counting for two different purposes:

  • Optimizing memory usage using a technique called "copy on write", where multiple variables holding the same value point to the same copy in memory. When any of the variables is modified, it is pointed to a new copy in memory, and the reference count on the original is decreased by 1.
  • Tracking variables which have been assigned or passed by reference (see References Explained). This refcount is stored on a separate reference zval, pointing to the zval for the current value. This additional zval is not currently shown by debug_zval_dump().

Because debug_zval_dump() takes its input as normal parameters, passed by value, the copy on write technique will be used to pass them: rather than copying the data, the refcount will be increased by one for the lifetime of the function call. If the function modified the parameter after receiving it, then a copy would be made; since it does not, it will show a refcount one higher than in the calling scope.

The parameter passing also prevents debug_zval_dump() showing variables which have been assigned by reference. To illustrate, consider a slightly modified version of the above example:

<?php
$var1 
'Hello';
$var1 .= ' World';
// Point three variables as references to the same value
$var2 =& $var1;
$var3 =& $var1;

debug_zval_dump($var1);
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

string(11) "Hello World" refcount(2)

Although $var1, $var2, and $var3 are linked as references, only the value is passed to debug_zval_dump(). That value is used once by the set of references, and once inside the debug_zval_dump(), so shows a refcount of 2.

Further complications arise because of optimisations made in the engine for different data types. Some types such as integers do not use "copy on write", so do not show a refcount at all. In other cases, the refcount shows extra copies used internally, such as when a literal string or array is stored as part of a code instruction.

Siehe auch

Hier Kannst Du einen Kommentar verfassen


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

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

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Definition von Stored Procedures - eine Einführung

Stored Procedures sind vordefinierte SQL-Codeblöcke, die in einer Datenbank gespeichert sind und bei Bedarf aufgerufen werden können. ...

Bernie

Autor : ebiz-consult GmbH & Co. KG
Kategorie: mySQL-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

Berechnungen durchführen

Hallo liebe Forenmitglieder, meine erste frage ist zum Aufbau meiner kleinen Berechnungswebseite, nichts kommerzielles, soll nur eine Anwendung f ...

Geschrieben von matze511 am 21.04.2024 21:42:37
Forum: PHP Developer Forum
Professioneller Webentwickler & Webdesigner

Of course, here is the translation: Hello, Thank you for your interest in the long-term project. Your extensive skills and experience in web dev ...

Geschrieben von Athelstan am 15.04.2024 09:25:39
Forum: Jobgesuche
Wir stellen unsere SEO-Agentur vor

Hallo In der heutigen digitalen Welt war es für Unternehmen noch nie so einfach, ihre Reichweite weltweit zu vergrößern. Wenn Sie außerhalb I ...

Geschrieben von thomasmuller am 14.04.2024 07:18:33
Forum: User stellen sich vor
Spielplan für 4 Gruppen zu je 6 Teams auf 2 Feldern

Hallöchen zusammen, ich versuche derzeit unseren Excel-Spielplan in PHP zu überführen. Eigentlich bin ich auch shon fertig - wenn da nicht dies ...

Geschrieben von derH0st am 11.04.2024 15:58:37
Forum: PHP Developer Forum