1--TEST--
2Test clone of DateTime objects
3--FILE--
4<?php
5//Set the default time zone
6date_default_timezone_set("Europe/London");
7
8echo "*** Testing clone on DateTime objects ***\n";
9
10echo "\n-- Create a DateTime object --\n";
11$d1 = new DateTime("2009-02-03 12:34:41 GMT");
12var_dump($d1);
13echo "\n-- Add some properties --\n";
14$d1->property1 = 99;
15$d1->property2 = "Hello";
16var_dump($d1);
17echo "\n-- clone it --\n";
18$d1_clone = clone $d1;
19var_dump($d1_clone);
20echo "\n-- Add some more properties --\n";
21$d1_clone->property3 = true;
22$d1_clone->property4 = 10.5;
23var_dump($d1_clone);
24echo "\n-- clone it --\n";
25$d2_clone = clone $d1_clone;
26var_dump($d2_clone);
27?>
28===DONE===
29--EXPECTF--
30*** Testing clone on DateTime objects ***
31
32-- Create a DateTime object --
33object(DateTime)#%d (3) {
34  ["date"]=>
35  string(19) "2009-02-03 12:34:41"
36  ["timezone_type"]=>
37  int(2)
38  ["timezone"]=>
39  string(3) "GMT"
40}
41
42-- Add some properties --
43object(DateTime)#%d (5) {
44  ["date"]=>
45  string(19) "2009-02-03 12:34:41"
46  ["timezone_type"]=>
47  int(2)
48  ["timezone"]=>
49  string(3) "GMT"
50  ["property1"]=>
51  int(99)
52  ["property2"]=>
53  string(5) "Hello"
54}
55
56-- clone it --
57object(DateTime)#%d (5) {
58  ["date"]=>
59  string(19) "2009-02-03 12:34:41"
60  ["timezone_type"]=>
61  int(2)
62  ["timezone"]=>
63  string(3) "GMT"
64  ["property1"]=>
65  int(99)
66  ["property2"]=>
67  string(5) "Hello"
68}
69
70-- Add some more properties --
71object(DateTime)#%d (7) {
72  ["date"]=>
73  string(19) "2009-02-03 12:34:41"
74  ["timezone_type"]=>
75  int(2)
76  ["timezone"]=>
77  string(3) "GMT"
78  ["property1"]=>
79  int(99)
80  ["property2"]=>
81  string(5) "Hello"
82  ["property3"]=>
83  bool(true)
84  ["property4"]=>
85  float(10.5)
86}
87
88-- clone it --
89object(DateTime)#%d (7) {
90  ["date"]=>
91  string(19) "2009-02-03 12:34:41"
92  ["timezone_type"]=>
93  int(2)
94  ["timezone"]=>
95  string(3) "GMT"
96  ["property1"]=>
97  int(99)
98  ["property2"]=>
99  string(5) "Hello"
100  ["property3"]=>
101  bool(true)
102  ["property4"]=>
103  float(10.5)
104}
105===DONE===
106