date_error.phpt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Test date() function : error conditions
  3. --FILE--
  4. <?php
  5. /* Prototype : string date ( string $format [, int $timestamp ] )
  6. * Description: Format a local time/date.
  7. * Source code: ext/date/php_date.c
  8. */
  9. echo "*** Testing date() : error conditions ***\n";
  10. //Set the default time zone
  11. date_default_timezone_set("America/Chicago");
  12. $format = "m.d.y";
  13. $timestamp = mktime(10, 44, 30, 2, 27, 2009);
  14. echo "\n-- Testing date function with no arguments --\n";
  15. var_dump (date());
  16. echo "\n-- Testing date function with more than expected no. of arguments --\n";
  17. $extra_arg = true;
  18. var_dump (checkdate($format, $timestamp, $extra_arg));
  19. ?>
  20. ===DONE===
  21. --EXPECTF--
  22. *** Testing date() : error conditions ***
  23. -- Testing date function with no arguments --
  24. Warning: date() expects at least 1 parameter, 0 given in %s on line %d
  25. bool(false)
  26. -- Testing date function with more than expected no. of arguments --
  27. Warning: checkdate() expects parameter 1 to be long, string given in %s on line %d
  28. bool(false)
  29. ===DONE===