3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Kitchen { private $yummy = 'cake'; } $reader = & function ($object, $property) { $value = Closure::bind(function & () use ($property) { return $this->$property; }, $object, $object)->__invoke(); return $value; }; $kitchen = new Kitchen(); $cake = & $reader($kitchen, 'yummy'); $cake = 'sorry, I ate it!'; var_dump($kitchen);
Output for 5.4.0 - 5.4.17
Parse error: syntax error, unexpected 'function' (T_FUNCTION) in /in/nN4p4 on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.26
Parse error: syntax error, unexpected T_FUNCTION in /in/nN4p4 on line 8
Process exited with code 255.

preferences:
182.83 ms | 1395 KiB | 52 Q