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