3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class PropertyTest { public function __set($name, $value) { echo "Setting '$name' to '$value'\n"; $this->data[$name] = $value; } public function __get($name) { echo "Getting '$name'\n"; if (array_key_exists($name, $this->data)) { return $this->data[$name]; }}public function __isset($name) { echo "Is '$name' set?\n"; return isset($this->data[$name]); } } echo "<pre>\n"; $obj = new PropertyTest; $obj->a = 1; echo $obj->a . "\n\n"; var_dump(isset($obj->a)); ?>
Output for 7.0.6 - 7.1.0
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/TrpHv on line 13 Notice: Indirect modification of overloaded property PropertyTest::$data has no effect in /in/TrpHv on line 8 Getting 'a' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/TrpHv on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/TrpHv on line 13 Is 'a' set? Is 'data' set? Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/TrpHv on line 13 bool(false)
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.0.5
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/TrpHv on line 13 Notice: Indirect modification of overloaded property PropertyTest::$data has no effect in /in/TrpHv on line 8 Getting 'a' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/TrpHv on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/TrpHv on line 13 Is 'a' set? Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/TrpHv on line 13 bool(false)
Output for hhvm-3.10.0 - 3.12.0
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: Invalid operand type was used: array_key_exists expects an array or an object; false returned. in /in/TrpHv on line 13 Getting 'a' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: Invalid operand type was used: array_key_exists expects an array or an object; false returned. in /in/TrpHv on line 13 Warning: Invalid operand type was used: array_key_exists expects an array or an object; false returned. in /in/TrpHv on line 13 Is 'a' set? Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: Invalid operand type was used: array_key_exists expects an array or an object; false returned. in /in/TrpHv on line 13 bool(false)
Output for 5.2.6 - 5.2.17
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 Notice: Indirect modification of overloaded property PropertyTest::$data has no effect in /in/TrpHv on line 8 Getting 'a' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 Is 'a' set? Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 bool(false)
Output for 5.2.1 - 5.2.5
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 Notice: Indirect modification of overloaded property PropertyTest::$data has no effect in /in/TrpHv on line 8 Getting 'a' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 Is 'a' set? Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 bool(false)
Output for 5.1.0 - 5.2.0
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 Getting 'a' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 Is 'a' set? Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 bool(false)
Output for 5.0.4 - 5.0.5
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 Getting 'a' Notice: Undefined property: PropertyTest::$data in /in/TrpHv on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/TrpHv on line 13 bool(false)
Output for 5.0.0 - 5.0.3
<pre> Setting 'a' to '1' Fatal error: Cannot access undefined property for object with overloaded property access in /in/TrpHv on line 8
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/TrpHv 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/TrpHv 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/TrpHv on line 5
Process exited with code 255.