3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $count; public function __construct() { $this->count = 1; } public function addCount() { $this->count++; } } class Bar { private $foo; private $array; public function __construct() { $this->foo = new Foo; $this->array = array(1, 2, 3); } public function getFoo() { return $this->foo; } public function getArray() { return $this->array; } } $bar = new Bar; $foo = $bar->getFoo(); $array = $bar->getArray(); var_dump($bar->getFoo()); print '<br>'; var_dump($foo); print '<br>'; var_dump($bar->getArray()); print '<br>'; var_dump($array); print '<br>'; $foo->addCount(); $array[] = 4; var_dump($bar->getFoo()); print '<br>'; var_dump($foo); print '<br>'; var_dump($bar->getArray()); print '<br>'; var_dump($array); print '<br>';

preferences:
45.62 ms | 402 KiB | 5 Q