3v4l.org

run code in 300+ PHP versions simultaneously
<?php class my_class { private $data; public $var1; public $var2; public $var3; public function __construct() { $this->data = new stdClass; $this->data->var1 = 'a'; $this->data->var2 = 'b'; $this->data->var3 = 'c'; $this->var1 = &$this->data->var1; $this->var2 = &$this->data->var2; $this->var3 = &$this->data->var3; } } $original = new my_class; var_dump($original); $new = clone $original; $new->var3 = 'd'; var_dump($new); // Output Should Be "c" echo $original->var3;
Output for git.master, git.master_jit, rfc.property-hooks
object(my_class)#1 (4) { ["data":"my_class":private]=> object(stdClass)#2 (3) { ["var1"]=> &string(1) "a" ["var2"]=> &string(1) "b" ["var3"]=> &string(1) "c" } ["var1"]=> &string(1) "a" ["var2"]=> &string(1) "b" ["var3"]=> &string(1) "c" } object(my_class)#3 (4) { ["data":"my_class":private]=> object(stdClass)#2 (3) { ["var1"]=> &string(1) "a" ["var2"]=> &string(1) "b" ["var3"]=> &string(1) "d" } ["var1"]=> &string(1) "a" ["var2"]=> &string(1) "b" ["var3"]=> &string(1) "d" } d

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:
47.89 ms | 402 KiB | 8 Q