3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { private $x; private $y; public function setX($x) { $this->x = $x; } public function setY($y) { $this->y = $y; } } class Bar extends Foo { public function __construct($x, $y) { $this->x = $x; $this->y = $y; } } $bar = new Bar(4,2); var_dump($bar); $bar->setX(8); $bar->setY(4); var_dump($bar);
based on pRBpL
Output for 5.3.0 - 7.2.0
object(Bar)#1 (4) { ["x":"Foo":private]=> NULL ["y":"Foo":private]=> NULL ["x"]=> int(4) ["y"]=> int(2) } object(Bar)#1 (4) { ["x":"Foo":private]=> int(8) ["y":"Foo":private]=> int(4) ["x"]=> int(4) ["y"]=> int(2) }
Output for 5.0.0 - 5.2.17
object(Bar)#1 (4) { ["x:private"]=> NULL ["y:private"]=> NULL ["x"]=> int(4) ["y"]=> int(2) } object(Bar)#1 (4) { ["x:private"]=> int(8) ["y:private"]=> int(4) ["x"]=> int(4) ["y"]=> int(2) }
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/uL9V7 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/uL9V7 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/uL9V7 on line 4
Process exited with code 255.