3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Test { private $a = 0; protected $b = true; public $c = 'hello'; } class Another extends Test { private $a = 1; protected $b = false; public $d ='wow'; } $obj = new Another(); $data = (array) $obj; $new = (object) $data; echo $new->c, $new->d, $new->b, $new->a; var_dump($data); var_dump($new);
Output for 5.5.0 - 7.1.0
hellowow Notice: Undefined property: stdClass::$b in /in/aFbJW on line 25 Notice: Undefined property: stdClass::$a in /in/aFbJW on line 25 array(5) { ["Anothera"]=> int(1) ["*b"]=> bool(false) ["d"]=> string(3) "wow" ["c"]=> string(5) "hello" ["Testa"]=> int(0) } object(stdClass)#2 (5) { ["a":"Another":private]=> int(1) ["b":protected]=> bool(false) ["d"]=> string(3) "wow" ["c"]=> string(5) "hello" ["a":"Test":private]=> int(0) }
Output for 5.4.0 - 5.4.45
hellowowarray(5) { ["Anothera"]=> int(1) ["*b"]=> bool(false) ["d"]=> string(3) "wow" ["c"]=> string(5) "hello" ["Testa"]=> int(0) } object(stdClass)#2 (5) { ["a":"Another":private]=> int(1) ["b":protected]=> bool(false) ["d"]=> string(3) "wow" ["c"]=> string(5) "hello" ["a":"Test":private]=> int(0) }
Output for 5.3.0 - 5.3.29
hellowowarray(5) { ["Anothera"]=> int(1) ["*b"]=> bool(false) ["d"]=> string(3) "wow" ["Testa"]=> int(0) ["c"]=> string(5) "hello" } object(stdClass)#2 (5) { ["a":"Another":private]=> int(1) ["b":protected]=> bool(false) ["d"]=> string(3) "wow" ["a":"Test":private]=> int(0) ["c"]=> string(5) "hello" }
Output for 5.0.0 - 5.2.17
hellowowarray(5) { ["Anothera"]=> int(1) ["*b"]=> bool(false) ["d"]=> string(3) "wow" ["Testa"]=> int(0) ["c"]=> string(5) "hello" } object(stdClass)#2 (5) { ["a:private"]=> int(1) ["b:protected"]=> bool(false) ["d"]=> string(3) "wow" ["a:private"]=> int(0) ["c"]=> string(5) "hello" }
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/aFbJW</b> on line <b>6</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/aFbJW</b> on line <b>6</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/aFbJW</b> on line <b>6</b><br />
Process exited with code 255.