3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $oink = 'foo'; } $foo = new Foo; class Bar extends Foo { public function __construct() { var_dump( get_object_vars($this), get_class($this), get_parent_class($this), $r = new ReflectionProperty($this, 'oink'), $r->getValue($this), $p = new ReflectionProperty(get_parent_class($this), 'oink'), $p->getValue($this) ); unset($this->oink); var_dump( get_object_vars($this), get_class($this), get_parent_class($this), $r = new ReflectionProperty($this, 'oink'), $r->getValue($this), $p = new ReflectionProperty(get_parent_class($this), 'oink'), $p->getValue($this) ); $this->oink = 'bar'; var_dump( get_object_vars($this), get_class($this), get_parent_class($this), $r = new ReflectionProperty($this, 'oink'), $r->getValue($this), $p = new ReflectionProperty(get_parent_class($this), 'oink'), $p->getValue($this) ); } } $bar = new Bar;
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.7
array(1) { ["oink"]=> string(3) "foo" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "foo" object(ReflectionProperty)#4 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "foo" Warning: Undefined property: Bar::$oink in /in/LbFki on line 32 Warning: Undefined property: Bar::$oink in /in/LbFki on line 34 array(0) { } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#5 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } NULL object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } NULL array(1) { ["oink"]=> string(3) "bar" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#4 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "bar" object(ReflectionProperty)#5 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "bar"
Output for 7.0.7 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
array(1) { ["oink"]=> string(3) "foo" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "foo" object(ReflectionProperty)#4 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "foo" Notice: Undefined property: Bar::$oink in /in/LbFki on line 32 Notice: Undefined property: Bar::$oink in /in/LbFki on line 34 array(0) { } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#5 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } NULL object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } NULL array(1) { ["oink"]=> string(3) "bar" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#4 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "bar" object(ReflectionProperty)#5 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "bar"
Output for 5.2.10 - 5.2.17, 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.6, 7.3.32 - 7.3.33, 7.4.26
array(1) { ["oink"]=> string(3) "foo" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "foo" object(ReflectionProperty)#4 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "foo" array(0) { } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#5 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } NULL object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } NULL array(1) { ["oink"]=> string(3) "bar" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#4 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "bar" object(ReflectionProperty)#5 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "bar"
Output for 5.2.0 - 5.2.9
array(1) { ["oink"]=> string(3) "foo" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Bar" } string(3) "foo" object(ReflectionProperty)#4 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "foo" array(0) { } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#5 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Bar" } NULL object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } NULL array(1) { ["oink"]=> string(3) "bar" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#4 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Bar" } string(3) "bar" object(ReflectionProperty)#5 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "bar"
Output for 5.1.3 - 5.1.6
array(1) { ["oink"]=> string(3) "foo" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Bar" } string(3) "foo" object(ReflectionProperty)#4 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "foo" Fatal error: Internal error: Could not find the property oink in /in/LbFki on line 32
Process exited with code 255.
Output for 5.0.3 - 5.0.5, 5.1.0 - 5.1.2
array(1) { ["oink"]=> string(3) "foo" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "foo" object(ReflectionProperty)#4 (2) { ["name"]=> string(4) "oink" ["class"]=> string(3) "Foo" } string(3) "foo" Fatal error: Internal error: Could not find the property oink in /in/LbFki on line 32
Process exited with code 255.
Output for 5.0.0 - 5.0.2
array(1) { ["oink"]=> string(3) "foo" } string(3) "Bar" string(3) "Foo" object(ReflectionProperty)#3 (2) { ["class"]=> string(3) "Foo" ["name"]=> string(4) "oink" } string(3) "foo" object(ReflectionProperty)#4 (2) { ["class"]=> string(3) "Foo" ["name"]=> string(4) "oink" } string(3) "foo" Fatal error: Internal error: Could not find the property oink in /in/LbFki on line 32
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/LbFki on line 6
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/LbFki on line 6
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/LbFki on line 6
Process exited with code 255.

preferences:
249.62 ms | 401 KiB | 386 Q