3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { public $publicProperty = 'bar'; } class FooWrapper extends Foo { private $wrapped; public function __construct(Foo $wrapped) { $this->wrapped = $foo; unset($this->publicProperty); } public function __get($name) { echo 'Getting property ' . $name . PHP_EOL; return $this->wrapped->$name; } public function __set($name, $value) { echo 'Setting property ' . $name . ' to ' . $value . PHP_EOL; return $this->wrapped->$name = $value; } } $foo = new FooWrapper(new Foo()); echo $foo->publicProperty; echo $foo->publicProperty = 'text';
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined variable: foo in /in/XIkND on line 12 Getting property publicProperty Notice: Trying to get property of non-object in /in/XIkND on line 20 Setting property publicProperty to text Warning: Creating default object from empty value in /in/XIkND on line 26 text
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined variable: foo in /in/XIkND on line 12 Getting property publicProperty Notice: Cannot access property on non-object in /in/XIkND on line 20 Setting property publicProperty to text Warning: Creating default object from empty value in /in/XIkND on line 26 text
Output for 5.0.4 - 5.3.29
Notice: Undefined variable: foo in /in/XIkND on line 12 Getting property publicProperty Notice: Trying to get property of non-object in /in/XIkND on line 20 Setting property publicProperty to text Strict Standards: Creating default object from empty value in /in/XIkND on line 26 text
Output for 5.0.2 - 5.0.3
Notice: Undefined variable: foo in /in/XIkND on line 12 Getting property publicProperty Notice: Trying to get property of non-object in /in/XIkND on line 20 Setting property publicProperty to text Strict Standards: Creating default object from empty value in /in/XIkND on line 26 text
Output for 5.0.0 - 5.0.1
Notice: Undefined variable: foo in /in/XIkND on line 12 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/XIkND on line 19 Getting property publicPropertyPHP_EOL Notice: Trying to get property of non-object in /in/XIkND on line 20 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/XIkND on line 25 Setting property publicProperty to textPHP_EOL Strict Standards: Creating default object from empty value in /in/XIkND on line 26 text
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/XIkND 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/XIkND 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/XIkND on line 4
Process exited with code 255.