3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $fooId; private $fooName; public void function __set($name, $value) { $this->$name = $value; } public function __get($name) { if (self::__isset($name)) { return $this->$name; } $trace = debug_backtrace(); trigger_error( 'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); return null; } public function __isset($name) { return isset($this->$name); } } $bar = new Foo(); $bar->fooId = 2; $bar->fooName = 'Name'; var_dump($bar);
Output for 5.4.0 - 5.4.14
Parse error: syntax error, unexpected 'void' (T_STRING), expecting variable (T_VARIABLE) in /in/TcPh4 on line 7
Process exited with code 255.
Output for 5.3.0 - 5.3.24
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/TcPh4 on line 7
Process exited with code 255.

preferences:
168.3 ms | 1386 KiB | 47 Q