3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { var $dateTime; var $string; public function __construct() { $this->dateTime = new \DateTime(); $this->string = 'foo'; } } $obj1 = new Foo(); $obj2 = clone $obj1; $obj1->string = 'foo bar'; $obj1->dateTime->add(new \DateInterval('P1D')); var_dump($obj1, $obj2);
based on hnpku
Output for 7.2.6
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.005689" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.005689" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 7.2.0
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.003671" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.003671" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 7.1.20
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.002561" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.002561" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 7.1.10
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.003797" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.003797" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 7.1.7
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.002965" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.002965" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 7.1.6
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.015334" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.015334" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 7.1.5
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.015069" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.015069" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 7.1.4
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.015060" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.015060" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.0.20, 7.1.3
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 7.1.2
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.014859" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.014859" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 7.1.1
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.004277" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.004277" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }
Output for 7.1.0
object(Foo)#1 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.004450" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(7) "foo bar" } object(Foo)#3 (2) { ["dateTime"]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2017-07-04 22:20:34.004450" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ["string"]=> string(3) "foo" }