1--TEST-- 2Test mktime() function : usage variation - Passing unexpected values to sixth argument $year. 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 sixth argument \$year***\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 12345' => 12345, 50 'int -12345' => -12345, 51 52 // float data 53 'float 10.5' => 10.5, 54 'float -10.5' => -10.5, 55 'float .5' => .5, 56 57 // array data 58 'empty array' => array(), 59 'int indexed array' => $index_array, 60 'associative array' => $assoc_array, 61 'nested arrays' => array('foo', $index_array, $assoc_array), 62 63 // null data 64 'uppercase NULL' => NULL, 65 'lowercase null' => null, 66 67 // boolean data 68 'lowercase true' => true, 69 'lowercase false' =>false, 70 'uppercase TRUE' =>TRUE, 71 'uppercase FALSE' =>FALSE, 72 73 // empty data 74 'empty string DQ' => "", 75 'empty string SQ' => '', 76 77 // string data 78 'string DQ' => "string", 79 'string SQ' => 'string', 80 'mixed case string' => "sTrInG", 81 'heredoc' => $heredoc, 82 83 // object data 84 'instance of classWithToString' => new classWithToString(), 85 'instance of classWithoutToString' => new classWithoutToString(), 86 87 // undefined data 88 'undefined var' => @$undefined_var, 89 90 // unset data 91 'unset var' => @$unset_var, 92 93 // resource 94 'resource' => $file_handle 95); 96 97$hour = 10; 98$minute = 30; 99$second = 45; 100$month = 7; 101$day = 2; 102 103foreach($inputs as $variation =>$year) { 104 echo "\n-- $variation --\n"; 105 var_dump( mktime($hour, $minute, $second, $month, $day, $year) ); 106}; 107 108// closing the resource 109fclose( $file_handle ); 110 111?> 112===DONE=== 113--EXPECTF-- 114*** Testing mktime() : usage variation - unexpected values to sixth argument $year*** 115 116-- int 0 -- 117int(%i) 118 119-- int 12345 -- 120%rint\(-?[1-9][0-9]*\)|bool\(false\)%r 121 122-- int -12345 -- 123%rint\(-?[1-9][0-9]*\)|bool\(false\)%r 124 125-- float 10.5 -- 126int(%i) 127 128-- float -10.5 -- 129%rint\(-?[1-9][0-9]*\)|bool\(false\)%r 130 131-- float .5 -- 132int(%i) 133 134-- empty array -- 135 136Warning: mktime() expects parameter 6 to be integer, array given in %s on line %d 137bool(false) 138 139-- int indexed array -- 140 141Warning: mktime() expects parameter 6 to be integer, array given in %s on line %d 142bool(false) 143 144-- associative array -- 145 146Warning: mktime() expects parameter 6 to be integer, array given in %s on line %d 147bool(false) 148 149-- nested arrays -- 150 151Warning: mktime() expects parameter 6 to be integer, array given in %s on line %d 152bool(false) 153 154-- uppercase NULL -- 155int(%i) 156 157-- lowercase null -- 158int(%i) 159 160-- lowercase true -- 161int(%i) 162 163-- lowercase false -- 164int(%i) 165 166-- uppercase TRUE -- 167int(%i) 168 169-- uppercase FALSE -- 170int(%i) 171 172-- empty string DQ -- 173 174Warning: mktime() expects parameter 6 to be integer, string given in %s on line %d 175bool(false) 176 177-- empty string SQ -- 178 179Warning: mktime() expects parameter 6 to be integer, string given in %s on line %d 180bool(false) 181 182-- string DQ -- 183 184Warning: mktime() expects parameter 6 to be integer, string given in %s on line %d 185bool(false) 186 187-- string SQ -- 188 189Warning: mktime() expects parameter 6 to be integer, string given in %s on line %d 190bool(false) 191 192-- mixed case string -- 193 194Warning: mktime() expects parameter 6 to be integer, string given in %s on line %d 195bool(false) 196 197-- heredoc -- 198 199Warning: mktime() expects parameter 6 to be integer, string given in %s on line %d 200bool(false) 201 202-- instance of classWithToString -- 203 204Warning: mktime() expects parameter 6 to be integer, object given in %s on line %d 205bool(false) 206 207-- instance of classWithoutToString -- 208 209Warning: mktime() expects parameter 6 to be integer, object given in %s on line %d 210bool(false) 211 212-- undefined var -- 213int(%i) 214 215-- unset var -- 216int(%i) 217 218-- resource -- 219 220Warning: mktime() expects parameter 6 to be integer, resource given in %s on line %d 221bool(false) 222===DONE=== 223