3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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) { return isset(self::$publicProperties[$name]) ? & $this->wrapped->$name : 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.3.0 - 5.5.0
Parse error: syntax error, unexpected '&' in /in/A6pe5 on line 25
Process exited with code 255.