3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { private $fooId; private $fooName; public 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); printf($bar->check);
Output for 5.3.0 - 7.1.0
object(Foo)#1 (2) { ["fooId":"Foo":private]=> int(2) ["fooName":"Foo":private]=> string(4) "Name" } Notice: Undefined property via __get(): check in /in/AEAlh on line 41 in /in/AEAlh on line 23
Output for 5.1.0 - 5.2.17
object(Foo)#1 (2) { ["fooId:private"]=> int(2) ["fooName:private"]=> string(4) "Name" } Notice: Undefined property via __get(): check in /in/AEAlh on line 41 in /in/AEAlh on line 23
Output for 5.0.0 - 5.0.5
Fatal error: Cannot access private property Foo::$fooId in /in/AEAlh on line 36
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/AEAlh on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/AEAlh on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/AEAlh on line 4
Process exited with code 255.