3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class test2 { public $foo = 'test'; } class test { private $arr; public function __construct() { $this->arr[0] = new test2(); $this->arr[1] = new test2(); } public function getArr() { return $this->arr; } } $t = new test(); var_dump($t->getArr()); $a = $t->getArr(); $a[0]->foo = 'bleh'; var_dump($t->getArr()); ?>
based on UfV5q
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0beta1
array(2) { [0]=> object(test2)#2 (1) { ["foo"]=> string(4) "test" } [1]=> object(test2)#3 (1) { ["foo"]=> string(4) "test" } } array(2) { [0]=> object(test2)#2 (1) { ["foo"]=> string(4) "bleh" } [1]=> object(test2)#3 (1) { ["foo"]=> string(4) "test" } }