3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { function __construct (&$arr) { $this->arr = &$arr; } function createInstance () { $reflectionClass = new ReflectionClass("Bar"); return $reflectionClass->newInstanceArgs(array($this, $this- >arr)); } function mod($key, $val) { $this->arr[$key] = $val; } } class Bar { function __construct (&$foo, &$arr) { $this->foo = &$foo; $this->arr = &$arr; } function mod($key, $val) { $this->arr[$key] = $val; } } $arr = array(); $foo = new Foo($arr); $arr["x"] = 1; $foo->mod("y", 2); $bar = $foo->createInstance(); $bar->mod("z", 3); var_dump($arr,$foo,$bar);
Output for 5.3.0 - 5.3.16, 5.4.0 - 5.4.6
Parse error: syntax error, unexpected '>' in SvkhP on line 9
Process exited with code 255.

preferences:
188.93 ms | 1395 KiB | 31 Q