3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $foo = 'foo'; protected $bar = 'bar'; } class FooProxy extends Some { private $wrapped; // ... private static $publicProperties = array('foo' => true); public function __construct(Foo $wrapped) { $this->wrapped = $wrapped; } public function & __get($name) { if (isset(self::$publicProperties[$name])) { return $this->wrapped->$name; } return PublicAccessEmulator::get($this->wrapped, $name); } } class PublicAccessEmulator { & public static function get($object, $name) { return & $object->$name; } } $foo = new FooProxy(new Foo()); var_dump($foo->foo); var_dump($foo->bar);
Output for 5.4.0 - 5.4.16
Parse error: syntax error, unexpected '&', expecting function (T_FUNCTION) in IDm3m on line 35
Process exited with code 255.
Output for 5.3.0 - 5.3.24, 5.3.26
Parse error: syntax error, unexpected '&', expecting T_FUNCTION in IDm3m on line 35
Process exited with code 255.
Output for 5.3.25
Parse error: syntax error, unexpected '&', expecting T_FUNCTION in /in/9ChMU on line 35
Process exited with code 255.

preferences:
177.35 ms | 1395 KiB | 51 Q