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'; } public function __clone() { $this->dateTime = clone $this->dateTime; } } $obj1 = new Foo(); $obj2 = clone $obj1; $obj1->string = 'foo bar'; $obj1->dateTime->add(new \DateInterval('P1Y')); var_dump($obj1->dateTime->format('Y-m-d')); var_dump($obj1->string); var_dump($obj2->dateTime->format('Y-m-d')); var_dump($obj2->string);
based on uoipu
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.6
string(10) "2018-07-03" string(7) "foo bar" string(10) "2017-07-03" string(3) "foo"