mktime_error.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Test mktime() function : error conditions
  3. --FILE--
  4. <?php
  5. /* Prototype : int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] )
  6. * Description: Get Unix timestamp for a date
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions:
  9. */
  10. error_reporting(E_ALL | E_STRICT);
  11. //Set the default time zone
  12. date_default_timezone_set("Europe/London");
  13. echo "*** Testing mktime() : error conditions ***\n";
  14. echo "\n-- Testing mktime() function with Zero arguments --\n";
  15. var_dump( mktime() );
  16. echo "\n-- Testing mktime() function with more than expected no. of arguments --\n";
  17. $hour = 10;
  18. $minute = 30;
  19. $sec = 45;
  20. $month = 7;
  21. $day = 2;
  22. $year = 1963;
  23. $is_dst = 0;
  24. $extra_arg = 10;
  25. var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $is_dst, $extra_arg) );
  26. ?>
  27. ===DONE===
  28. --EXPECTF--
  29. *** Testing mktime() : error conditions ***
  30. -- Testing mktime() function with Zero arguments --
  31. Strict Standards: mktime(): You should be using the time() function instead in %s on line %d
  32. int(%d)
  33. -- Testing mktime() function with more than expected no. of arguments --
  34. Warning: mktime() expects at most 7 parameters, 8 given in %s on line %d
  35. bool(false)
  36. ===DONE===