- var_dump: documentation ( source)
<?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);