3v4l.org

run code in 300+ PHP versions simultaneously
<?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]; }}} echo "<pre>\n"; $obj = new PropertyTest; $obj->a = 1; echo $obj->a . "\n\n"; ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<pre> Setting 'a' to '1' Getting 'data' Warning: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /in/WKL9N:13 Stack trace: #0 /in/WKL9N(8): PropertyTest->__get('data') #1 /in/WKL9N(21): PropertyTest->__set('a', 1) #2 {main} thrown in /in/WKL9N on line 13
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/WKL9N on line 13 Notice: Indirect modification of overloaded property PropertyTest::$data has no effect in /in/WKL9N on line 8 Getting 'a' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/WKL9N on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/WKL9N on line 13
Output for 7.3.32 - 7.3.33
<pre> Setting 'a' to '1' Getting 'data' Warning: array_key_exists() expects parameter 2 to be array, null given in /in/WKL9N on line 13 Getting 'a' Getting 'data' Warning: array_key_exists() expects parameter 2 to be array, null given in /in/WKL9N on line 13 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/WKL9N on line 13
Output for 5.2.6 - 5.2.17
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13 Notice: Indirect modification of overloaded property PropertyTest::$data has no effect in /in/WKL9N on line 8 Getting 'a' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13
Output for 5.2.1 - 5.2.5
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13 Notice: Indirect modification of overloaded property PropertyTest::$data has no effect in /in/WKL9N on line 8 Getting 'a' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13
Output for 5.1.0 - 5.1.6, 5.2.0
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13 Getting 'a' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13
Output for 5.0.4 - 5.0.5
<pre> Setting 'a' to '1' Getting 'data' Notice: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13 Getting 'a' Notice: Undefined property: PropertyTest::$data in /in/WKL9N on line 13 Warning: array_key_exists(): The second argument should be either an array or an object in /in/WKL9N on line 13
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/WKL9N 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/WKL9N on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/WKL9N 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/WKL9N on line 5
Process exited with code 255.

preferences:
252.45 ms | 401 KiB | 371 Q