3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $ref; function __construct () { $this->ref = new class() { public $name; }; } public function create (string $name) { $this->ref->name = $name; return clone $this->ref; } } $A = new A(); $testA = $A->create("matti"); $testB = $A->create("Pekka"); var_dump($testA); var_dump($testB);
Output for git.master, git.master_jit, rfc.property-hooks
object(class@anonymous)#3 (1) { ["name"]=> string(5) "matti" } object(class@anonymous)#4 (1) { ["name"]=> string(5) "Pekka" }

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:
69.39 ms | 401 KiB | 8 Q