3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class NoIsset { public $data; public function __construct(array $data) { $this->data = $data; } public function __get($name) { return $this->data[$name]; } } class HasIsset extends NoIsset { public function __isset($name) { return isset($this->data[$name]); } } $data = array('one' => 1, 'two' => 2, 'three' => 3); $no_isset = new NoIsset($data); $has_isset = new HasIsset($data); if (empty($no_isset->one)) echo "NoIsset doesn't have one\n"; else echo "NoIsset has one\n"; if (empty($has_isset->one)) echo "HasIsset doesn't have one\n"; else echo "HasIsset has one\n";
Output for 5.1.0 - 7.1.0
NoIsset doesn't have one HasIsset has one
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/LvJO0 on line 7
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/LvJO0 on line 5
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/LvJO0 on line 5
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/LvJO0 on line 5
Process exited with code 255.