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>';<?php
Output for 5.3.0 - 5.3.27, 5.4.0 - 5.4.21
Parse error: syntax error, unexpected '<' in /in/4QT9I on line 58
Process exited with code 255.

preferences:
190.38 ms | 1399 KiB | 57 Q