1--TEST-- 2Test idate() function : usage variation - Passing unexpected values to first argument 'format'. 3--FILE-- 4<?php 5/* Prototype : int idate(string format [, int timestamp]) 6 * Description: Format a local time/date as integer 7 * Source code: ext/date/php_date.c 8 * Alias to functions: 9 */ 10 11echo "*** Testing idate() : usage variation ***\n"; 12 13// Initialise function arguments not being substituted (if any) 14date_default_timezone_set("Asia/Calcutta"); 15$timestamp = mktime(8, 8, 8, 8, 8, 2008); 16 17//get an unset variable 18$unset_var = 10; 19unset ($unset_var); 20 21// define some classes 22class classWithToString 23{ 24 public function __toString() { 25 return "Class A object"; 26 } 27} 28 29class classWithoutToString 30{ 31} 32 33// heredoc string 34$heredoc = <<<EOT 35hello world 36EOT; 37 38// add arrays 39$index_array = array (1, 2, 3); 40$assoc_array = array ('one' => 1, 'two' => 2); 41 42//array of values to iterate over 43$inputs = array( 44 45 // int data 46 'int 0' => 0, 47 'int 1' => 1, 48 'int 12345' => 12345, 49 'int -12345' => -12345, 50 51 // float data 52 'float 10.5' => 10.5, 53 'float -10.5' => -10.5, 54 'float 12.3456789000e10' => 12.3456789000e10, 55 'float -12.3456789000e10' => -12.3456789000e10, 56 'float .5' => .5, 57 58 // array data 59 'empty array' => array(), 60 'int indexed array' => $index_array, 61 'associative array' => $assoc_array, 62 'nested arrays' => array('foo', $index_array, $assoc_array), 63 64 // null data 65 'uppercase NULL' => NULL, 66 'lowercase null' => null, 67 68 // boolean data 69 'lowercase true' => true, 70 'lowercase false' =>false, 71 'uppercase TRUE' =>TRUE, 72 'uppercase FALSE' =>FALSE, 73 74 // empty data 75 'empty string DQ' => "", 76 'empty string SQ' => '', 77 78 // object data 79 'instance of classWithToString' => new classWithToString(), 80 'instance of classWithoutToString' => new classWithoutToString(), 81 82 // undefined data 83 'undefined var' => @$undefined_var, 84 85 // unset data 86 'unset var' => @$unset_var, 87); 88 89// loop through each element of the array for format 90 91foreach($inputs as $key =>$value) { 92 echo "\n--$key--\n"; 93 var_dump( idate($value) ); 94 var_dump( idate($value, $timestamp) ); 95}; 96 97?> 98===DONE=== 99--EXPECTF-- 100*** Testing idate() : usage variation *** 101 102--int 0-- 103 104Warning: idate(): Unrecognized date format token. in %s on line %d 105bool(false) 106 107Warning: idate(): Unrecognized date format token. in %s on line %d 108bool(false) 109 110--int 1-- 111 112Warning: idate(): Unrecognized date format token. in %s on line %d 113bool(false) 114 115Warning: idate(): Unrecognized date format token. in %s on line %d 116bool(false) 117 118--int 12345-- 119 120Warning: idate(): idate format is one char in %s on line %d 121bool(false) 122 123Warning: idate(): idate format is one char in %s on line %d 124bool(false) 125 126--int -12345-- 127 128Warning: idate(): idate format is one char in %s on line %d 129bool(false) 130 131Warning: idate(): idate format is one char in %s on line %d 132bool(false) 133 134--float 10.5-- 135 136Warning: idate(): idate format is one char in %s on line %d 137bool(false) 138 139Warning: idate(): idate format is one char in %s on line %d 140bool(false) 141 142--float -10.5-- 143 144Warning: idate(): idate format is one char in %s on line %d 145bool(false) 146 147Warning: idate(): idate format is one char in %s on line %d 148bool(false) 149 150--float 12.3456789000e10-- 151 152Warning: idate(): idate format is one char in %s on line %d 153bool(false) 154 155Warning: idate(): idate format is one char in %s on line %d 156bool(false) 157 158--float -12.3456789000e10-- 159 160Warning: idate(): idate format is one char in %s on line %d 161bool(false) 162 163Warning: idate(): idate format is one char in %s on line %d 164bool(false) 165 166--float .5-- 167 168Warning: idate(): idate format is one char in %s on line %d 169bool(false) 170 171Warning: idate(): idate format is one char in %s on line %d 172bool(false) 173 174--empty array-- 175 176Warning: idate() expects parameter 1 to be string, array given in %s on line %d 177bool(false) 178 179Warning: idate() expects parameter 1 to be string, array given in %s on line %d 180bool(false) 181 182--int indexed array-- 183 184Warning: idate() expects parameter 1 to be string, array given in %s on line %d 185bool(false) 186 187Warning: idate() expects parameter 1 to be string, array given in %s on line %d 188bool(false) 189 190--associative array-- 191 192Warning: idate() expects parameter 1 to be string, array given in %s on line %d 193bool(false) 194 195Warning: idate() expects parameter 1 to be string, array given in %s on line %d 196bool(false) 197 198--nested arrays-- 199 200Warning: idate() expects parameter 1 to be string, array given in %s on line %d 201bool(false) 202 203Warning: idate() expects parameter 1 to be string, array given in %s on line %d 204bool(false) 205 206--uppercase NULL-- 207 208Warning: idate(): idate format is one char in %s on line %d 209bool(false) 210 211Warning: idate(): idate format is one char in %s on line %d 212bool(false) 213 214--lowercase null-- 215 216Warning: idate(): idate format is one char in %s on line %d 217bool(false) 218 219Warning: idate(): idate format is one char in %s on line %d 220bool(false) 221 222--lowercase true-- 223 224Warning: idate(): Unrecognized date format token. in %s on line %d 225bool(false) 226 227Warning: idate(): Unrecognized date format token. in %s on line %d 228bool(false) 229 230--lowercase false-- 231 232Warning: idate(): idate format is one char in %s on line %d 233bool(false) 234 235Warning: idate(): idate format is one char in %s on line %d 236bool(false) 237 238--uppercase TRUE-- 239 240Warning: idate(): Unrecognized date format token. in %s on line %d 241bool(false) 242 243Warning: idate(): Unrecognized date format token. in %s on line %d 244bool(false) 245 246--uppercase FALSE-- 247 248Warning: idate(): idate format is one char in %s on line %d 249bool(false) 250 251Warning: idate(): idate format is one char in %s on line %d 252bool(false) 253 254--empty string DQ-- 255 256Warning: idate(): idate format is one char in %s on line %d 257bool(false) 258 259Warning: idate(): idate format is one char in %s on line %d 260bool(false) 261 262--empty string SQ-- 263 264Warning: idate(): idate format is one char in %s on line %d 265bool(false) 266 267Warning: idate(): idate format is one char in %s on line %d 268bool(false) 269 270--instance of classWithToString-- 271 272Warning: idate(): idate format is one char in %s on line %d 273bool(false) 274 275Warning: idate(): idate format is one char in %s on line %d 276bool(false) 277 278--instance of classWithoutToString-- 279 280Warning: idate() expects parameter 1 to be string, object given in %s on line %d 281bool(false) 282 283Warning: idate() expects parameter 1 to be string, object given in %s on line %d 284bool(false) 285 286--undefined var-- 287 288Warning: idate(): idate format is one char in %s on line %d 289bool(false) 290 291Warning: idate(): idate format is one char in %s on line %d 292bool(false) 293 294--unset var-- 295 296Warning: idate(): idate format is one char in %s on line %d 297bool(false) 298 299Warning: idate(): idate format is one char in %s on line %d 300bool(false) 301===DONE=== 302