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--EXPECTF--
29*** Testing clone on DateTime objects ***
30
31-- Create a DateTime object --
32object(DateTime)#%d (3) {
33  ["date"]=>
34  string(26) "2009-02-03 12:34:41.000000"
35  ["timezone_type"]=>
36  int(2)
37  ["timezone"]=>
38  string(3) "GMT"
39}
40
41-- Add some properties --
42
43Deprecated: Creation of dynamic property DateTime::$property1 is deprecated in %s on line %d
44
45Deprecated: Creation of dynamic property DateTime::$property2 is deprecated in %s on line %d
46object(DateTime)#%d (5) {
47  ["property1"]=>
48  int(99)
49  ["property2"]=>
50  string(5) "Hello"
51  ["date"]=>
52  string(26) "2009-02-03 12:34:41.000000"
53  ["timezone_type"]=>
54  int(2)
55  ["timezone"]=>
56  string(3) "GMT"
57}
58
59-- clone it --
60object(DateTime)#%d (5) {
61  ["property1"]=>
62  int(99)
63  ["property2"]=>
64  string(5) "Hello"
65  ["date"]=>
66  string(26) "2009-02-03 12:34:41.000000"
67  ["timezone_type"]=>
68  int(2)
69  ["timezone"]=>
70  string(3) "GMT"
71}
72
73-- Add some more properties --
74
75Deprecated: Creation of dynamic property DateTime::$property3 is deprecated in %s on line %d
76
77Deprecated: Creation of dynamic property DateTime::$property4 is deprecated in %s on line %d
78object(DateTime)#%d (7) {
79  ["property1"]=>
80  int(99)
81  ["property2"]=>
82  string(5) "Hello"
83  ["property3"]=>
84  bool(true)
85  ["property4"]=>
86  float(10.5)
87  ["date"]=>
88  string(26) "2009-02-03 12:34:41.000000"
89  ["timezone_type"]=>
90  int(2)
91  ["timezone"]=>
92  string(3) "GMT"
93}
94
95-- clone it --
96object(DateTime)#%d (7) {
97  ["property1"]=>
98  int(99)
99  ["property2"]=>
100  string(5) "Hello"
101  ["property3"]=>
102  bool(true)
103  ["property4"]=>
104  float(10.5)
105  ["date"]=>
106  string(26) "2009-02-03 12:34:41.000000"
107  ["timezone_type"]=>
108  int(2)
109  ["timezone"]=>
110  string(3) "GMT"
111}
112