DateTime_clone_basic4.phpt 823 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Test clone of DateTime derived objects with __clone magic method
  3. --FILE--
  4. <?php
  5. //Set the default time zone
  6. date_default_timezone_set("Europe/London");
  7. //Set the default time zone
  8. date_default_timezone_set("Europe/London");
  9. class DateTimeExt1 extends DateTime {
  10. public function __clone() {
  11. echo "-- DateTimeExt1 __clone magic method called --\n";
  12. }
  13. }
  14. echo "*** Testing clone of objects derived from DateTime class with __clone magic method***\n";
  15. $d1 = new DateTimeExt1("2009-02-03 12:34:41 GMT");
  16. $d1_clone = clone $d1;
  17. //verify clone by calling method on new object
  18. var_dump( $d1_clone->format( "m.d.y") );
  19. ?>
  20. ===DONE===
  21. --EXPECTF--
  22. *** Testing clone of objects derived from DateTime class with __clone magic method***
  23. -- DateTimeExt1 __clone magic method called --
  24. string(8) "02.03.09"
  25. ===DONE===