]> granicus.if.org Git - php/blob
e40e40f38d
[php] /
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
11 //Set the default time zone
12 date_default_timezone_set("Europe/London");
13
14 echo "*** Testing mktime() : error conditions ***\n";
15
16 echo "\n-- Testing mktime() function with Zero arguments --\n";
17 try {
18     var_dump( mktime() );
19 } catch (TypeError $e) {
20     echo $e->getMessage(), "\n";
21 }
22
23 echo "\n-- Testing mktime() function with more than expected no. of arguments --\n";
24 $hour = 10;
25 $minute = 30;
26 $sec = 45;
27 $month = 7;
28 $day = 2;
29 $year = 1963;
30 $extra_arg = 10;
31 try {
32     var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $extra_arg) );
33 } catch (TypeError $e) {
34     echo $e->getMessage(), "\n";
35 }
36
37 ?>
38 --EXPECTF--
39 *** Testing mktime() : error conditions ***
40
41 -- Testing mktime() function with Zero arguments --
42 mktime() expects at least 1 parameter, 0 given
43
44 -- Testing mktime() function with more than expected no. of arguments --
45 mktime() expects at most 6 parameters, 7 given