3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { public $bar = null; public function __construct() { $this->bar = new DateTime(); // Now $this->far = &$this->bar; } } $foo= new Foo(); var_dump($foo); $vars = get_object_vars($foo); $vars['bar'] = new DateTime('2014-03-25'); var_dump($foo);
Output for 7.1.0
object(Foo)#1 (2) { ["bar"]=> &object(DateTime)#2 (3) { ["date"]=> string(26) "2016-10-14 09:59:42.004140" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["far"]=> &object(DateTime)#2 (3) { ["date"]=> string(26) "2016-10-14 09:59:42.004140" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } } object(Foo)#1 (2) { ["bar"]=> &object(DateTime)#3 (3) { ["date"]=> string(26) "2014-03-25 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["far"]=> &object(DateTime)#3 (3) { ["date"]=> string(26) "2014-03-25 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } }
Output for 5.4.30 - 5.4.45, 5.5.14 - 7.0.14
object(Foo)#1 (2) { ["bar"]=> &object(DateTime)#2 (3) { ["date"]=> string(26) "2016-10-14 09:59:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["far"]=> &object(DateTime)#2 (3) { ["date"]=> string(26) "2016-10-14 09:59:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } } object(Foo)#1 (2) { ["bar"]=> &object(DateTime)#3 (3) { ["date"]=> string(26) "2014-03-25 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["far"]=> &object(DateTime)#3 (3) { ["date"]=> string(26) "2014-03-25 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } }
Output for 5.3.0 - 5.4.29, 5.5.0 - 5.5.13
object(Foo)#1 (2) { ["bar"]=> &object(DateTime)#2 (3) { ["date"]=> string(19) "2016-10-14 09:59:42" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["far"]=> &object(DateTime)#2 (3) { ["date"]=> string(19) "2016-10-14 09:59:42" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } } object(Foo)#1 (2) { ["bar"]=> &object(DateTime)#3 (3) { ["date"]=> string(19) "2014-03-25 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["far"]=> &object(DateTime)#3 (3) { ["date"]=> string(19) "2014-03-25 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } }
Output for 5.2.0 - 5.2.17
object(Foo)#1 (2) { ["bar"]=> &object(DateTime)#2 (0) { } ["far"]=> &object(DateTime)#2 (0) { } } object(Foo)#1 (2) { ["bar"]=> &object(DateTime)#3 (0) { } ["far"]=> &object(DateTime)#3 (0) { } }
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/H7h4N on line 6
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/H7h4N 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/H7h4N 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/H7h4N on line 4
Process exited with code 255.