1--TEST--
2Test mktime() function : usage variation - Passing unexpected values to seventh argument $is_dst.
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
11echo "*** Testing mktime() : usage variation -  unexpected values to seventh argument \$is_dst***\n";
12
13//Set the default time zone
14date_default_timezone_set("Europe/London");
15
16//get an unset variable
17$unset_var = 10;
18unset ($unset_var);
19
20// define some classes
21class classWithToString
22{
23	public function __toString() {
24		return "Class A object";
25	}
26}
27
28class classWithoutToString
29{
30}
31
32// heredoc string
33$heredoc = <<<EOT
34hello world
35EOT;
36
37// add arrays
38$index_array = array (1, 2, 3);
39$assoc_array = array ('one' => 1, 'two' => 2);
40
41// resource
42$file_handle = fopen(__FILE__, 'r');
43
44//array of values to iterate over
45$inputs = array(
46
47      // int data
48      'int 0' => 0,
49      'int 0' => 1,
50      'int 0' => -1,
51      'int 12345' => 12345,
52      'int -12345' => -12345,
53
54      // float data
55      'float 10.5' => 10.5,
56      'float -10.5' => -10.5,
57      'float .5' => .5,
58
59      // array data
60      'empty array' => array(),
61      'int indexed array' => $index_array,
62      'associative array' => $assoc_array,
63      'nested arrays' => array('foo', $index_array, $assoc_array),
64
65      // null data
66      'uppercase NULL' => NULL,
67      'lowercase null' => null,
68
69      // boolean data
70      'lowercase true' => true,
71      'lowercase false' =>false,
72      'uppercase TRUE' =>TRUE,
73      'uppercase FALSE' =>FALSE,
74
75      // empty data
76      'empty string DQ' => "",
77      'empty string SQ' => '',
78
79      // string data
80      'string DQ' => "string",
81      'string SQ' => 'string',
82      'mixed case string' => "sTrInG",
83      'heredoc' => $heredoc,
84
85      // object data
86      'instance of classWithToString' => new classWithToString(),
87      'instance of classWithoutToString' => new classWithoutToString(),
88
89      // undefined data
90      'undefined var' => @$undefined_var,
91
92      // unset data
93      'unset var' => @$unset_var,
94
95      // resource
96      'resource' => $file_handle
97);
98
99$hour = 10;
100$minute = 30;
101$second = 45;
102$month = 7;
103$day = 2;
104$year = 1963;
105
106foreach($inputs as $variation =>$is_dst) {
107      echo "\n-- $variation --\n";
108      var_dump( mktime($hour, $minute, $second, $month, $day, $year, $is_dst) );
109};
110
111// closing the resource
112fclose( $file_handle );
113
114?>
115===DONE===
116--EXPECTF--
117*** Testing mktime() : usage variation -  unexpected values to seventh argument $is_dst***
118
119-- int 0 --
120int(%i)
121
122-- int 12345 --
123
124Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
125int(%i)
126
127-- int -12345 --
128
129Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
130int(%i)
131
132-- float 10.5 --
133
134Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
135int(-205165755)
136
137-- float -10.5 --
138
139Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
140int(%i)
141
142-- float .5 --
143
144Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
145int(-205162155)
146
147-- empty array --
148
149Warning: mktime() expects parameter 7 to be long, array given in %s on line %d
150bool(false)
151
152-- int indexed array --
153
154Warning: mktime() expects parameter 7 to be long, array given in %s on line %d
155bool(false)
156
157-- associative array --
158
159Warning: mktime() expects parameter 7 to be long, array given in %s on line %d
160bool(false)
161
162-- nested arrays --
163
164Warning: mktime() expects parameter 7 to be long, array given in %s on line %d
165bool(false)
166
167-- uppercase NULL --
168
169Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
170int(%i)
171
172-- lowercase null --
173
174Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
175int(%i)
176
177-- lowercase true --
178
179Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
180int(%i)
181
182-- lowercase false --
183
184Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
185int(%i)
186
187-- uppercase TRUE --
188
189Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
190int(%i)
191
192-- uppercase FALSE --
193
194Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
195int(%i)
196
197-- empty string DQ --
198
199Warning: mktime() expects parameter 7 to be long, string given in %s on line %d
200bool(false)
201
202-- empty string SQ --
203
204Warning: mktime() expects parameter 7 to be long, string given in %s on line %d
205bool(false)
206
207-- string DQ --
208
209Warning: mktime() expects parameter 7 to be long, string given in %s on line %d
210bool(false)
211
212-- string SQ --
213
214Warning: mktime() expects parameter 7 to be long, string given in %s on line %d
215bool(false)
216
217-- mixed case string --
218
219Warning: mktime() expects parameter 7 to be long, string given in %s on line %d
220bool(false)
221
222-- heredoc --
223
224Warning: mktime() expects parameter 7 to be long, string given in %s on line %d
225bool(false)
226
227-- instance of classWithToString --
228
229Warning: mktime() expects parameter 7 to be long, object given in %s on line %d
230bool(false)
231
232-- instance of classWithoutToString --
233
234Warning: mktime() expects parameter 7 to be long, object given in %s on line %d
235bool(false)
236
237-- undefined var --
238
239Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
240int(%i)
241
242-- unset var --
243
244Deprecated: mktime(): The is_dst parameter is deprecated in %s on line %d
245int(%i)
246
247-- resource --
248
249Warning: mktime() expects parameter 7 to be long, resource given in %s on line %d
250bool(false)
251===DONE===
252