3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyClass { private $prop; public function __construct($prop) { $this->prop = $prop; } public function withProp($prop) { // immutable $copy = clone $this; $copy->prop = $prop; return $copy; } public function setProp($prop) { // mutable $this->prop = $prop; } public function getProp() { return $this->prop; } } $obj = new MyClass('A'); $obj = $obj->withProp('B'); echo $obj->getProp();
Output for 5.5.0 - 7.3.1
B