3v4l.org

run code in 300+ PHP versions simultaneously
<?php class House { /** * @var string */ private $size; public function __construct(string $size) { $this->size = $size; } public function getSize() : string { return $this->size; } public function withSize(string $newSize) : House { $clone = clone $this; $clone->size = $newSize; //note that $size field had to be changed to public return $clone; } } $house = new House('small'); $bigHouse = $house->withSize('big'); echo $house->getSize();
Output for git.master, git.master_jit, rfc.property-hooks
small

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:
152.39 ms | 405 KiB | 5 Q