1--TEST-- 2Test gmmktime() function : usage variation - Passing unexpected values to fourth argument month. 3--FILE-- 4<?php 5/* Prototype : int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]]) 6 * Description: Get UNIX timestamp for a GMT date 7 * Source code: ext/date/php_date.c 8 * Alias to functions: 9 */ 10 11echo "*** Testing gmmktime() : usage variation ***\n"; 12 13// Initialise function arguments not being substituted (if any) 14$hour = 8; 15$min = 8; 16$sec = 8; 17$day = 8; 18$year = 2008; 19 20//get an unset variable 21$unset_var = 10; 22unset ($unset_var); 23 24// define some classes 25class classWithToString 26{ 27 public function __toString() { 28 return "Class A object"; 29 } 30} 31 32class classWithoutToString 33{ 34} 35 36// heredoc string 37$heredoc = <<<EOT 38hello world 39EOT; 40 41// add arrays 42$index_array = array (1, 2, 3); 43$assoc_array = array ('one' => 1, 'two' => 2); 44 45//array of values to iterate over 46$inputs = array( 47 48 // float data 49 'float 10.5' => 10.5, 50 'float -10.5' => -10.5, 51 'float .5' => .5, 52 53 // array data 54 'empty array' => array(), 55 'int indexed array' => $index_array, 56 'associative array' => $assoc_array, 57 'nested arrays' => array('foo', $index_array, $assoc_array), 58 59 // null data 60 'uppercase NULL' => NULL, 61 'lowercase null' => null, 62 63 // boolean data 64 'lowercase true' => true, 65 'lowercase false' =>false, 66 'uppercase TRUE' =>TRUE, 67 'uppercase FALSE' =>FALSE, 68 69 // empty data 70 'empty string DQ' => "", 71 'empty string SQ' => '', 72 73 // string data 74 'string DQ' => "string", 75 'string SQ' => 'string', 76 'mixed case string' => "sTrInG", 77 'heredoc' => $heredoc, 78 79 // object data 80 'instance of classWithToString' => new classWithToString(), 81 'instance of classWithoutToString' => new classWithoutToString(), 82 83 // undefined data 84 'undefined var' => @$undefined_var, 85 86 // unset data 87 'unset var' => @$unset_var, 88); 89 90// loop through each element of the array for mon 91 92foreach($inputs as $key =>$value) { 93 echo "\n--$key--\n"; 94 var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) ); 95}; 96 97?> 98===DONE=== 99--EXPECTF-- 100*** Testing gmmktime() : usage variation *** 101 102--float 10.5-- 103int(1223453288) 104 105--float -10.5-- 106int(1170922088) 107 108--float .5-- 109int(1197101288) 110 111--empty array-- 112 113Warning: gmmktime() expects parameter 4 to be long, array given in %s on line %d 114bool(false) 115 116--int indexed array-- 117 118Warning: gmmktime() expects parameter 4 to be long, array given in %s on line %d 119bool(false) 120 121--associative array-- 122 123Warning: gmmktime() expects parameter 4 to be long, array given in %s on line %d 124bool(false) 125 126--nested arrays-- 127 128Warning: gmmktime() expects parameter 4 to be long, array given in %s on line %d 129bool(false) 130 131--uppercase NULL-- 132int(1197101288) 133 134--lowercase null-- 135int(1197101288) 136 137--lowercase true-- 138int(1199779688) 139 140--lowercase false-- 141int(1197101288) 142 143--uppercase TRUE-- 144int(1199779688) 145 146--uppercase FALSE-- 147int(1197101288) 148 149--empty string DQ-- 150 151Warning: gmmktime() expects parameter 4 to be long, string given in %s on line %d 152bool(false) 153 154--empty string SQ-- 155 156Warning: gmmktime() expects parameter 4 to be long, string given in %s on line %d 157bool(false) 158 159--string DQ-- 160 161Warning: gmmktime() expects parameter 4 to be long, string given in %s on line %d 162bool(false) 163 164--string SQ-- 165 166Warning: gmmktime() expects parameter 4 to be long, string given in %s on line %d 167bool(false) 168 169--mixed case string-- 170 171Warning: gmmktime() expects parameter 4 to be long, string given in %s on line %d 172bool(false) 173 174--heredoc-- 175 176Warning: gmmktime() expects parameter 4 to be long, string given in %s on line %d 177bool(false) 178 179--instance of classWithToString-- 180 181Warning: gmmktime() expects parameter 4 to be long, object given in %s on line %d 182bool(false) 183 184--instance of classWithoutToString-- 185 186Warning: gmmktime() expects parameter 4 to be long, object given in %s on line %d 187bool(false) 188 189--undefined var-- 190int(1197101288) 191 192--unset var-- 193int(1197101288) 194===DONE=== 195