3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Tablier { public function __construct(public float $longueur, public float $largeur){ } } class Pont { private $taille = null; public function __sleep() { return array('name','tablier'); } public function __wakeup() { $this->taille = fn() => $this->tablier->longueur * $this->tablier->largeur; } public function __construct(protected string $name, protected Tablier $tablier) { $this->taille = fn() => $this->tablier->longueur * $this->tablier->largeur; } public function __clone(){ $this->tablier = clone $this->tablier; } } $pont1 = new Pont("towerBridge", new Tablier(386,16)); var_dump($pont1); $pont2 = clone $pont1; $chaine = serialize($pont1); echo $chaine; $pont3 = unserialize($chaine); var_dump($pont3);
Output for git.master, git.master_jit, rfc.property-hooks
object(Pont)#1 (3) { ["taille":"Pont":private]=> object(Closure)#3 (1) { ["this"]=> *RECURSION* } ["name":protected]=> string(11) "towerBridge" ["tablier":protected]=> object(Tablier)#2 (2) { ["longueur"]=> float(386) ["largeur"]=> float(16) } } O:4:"Pont":2:{s:7:"*name";s:11:"towerBridge";s:10:"*tablier";O:7:"Tablier":2:{s:8:"longueur";d:386;s:7:"largeur";d:16;}}object(Pont)#6 (3) { ["taille":"Pont":private]=> object(Closure)#8 (1) { ["this"]=> *RECURSION* } ["name":protected]=> string(11) "towerBridge" ["tablier":protected]=> object(Tablier)#7 (2) { ["longueur"]=> float(386) ["largeur"]=> float(16) } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
38.91 ms | 402 KiB | 8 Q