1--TEST-- 2Test gmstrftime() function : usage variation - Passing unexpected values to second argument 'timestamp'. 3--SKIPIF-- 4<?php 5if(PHP_INT_SIZE != 4 ) { 6 die("skip Test is not valid for 64-bit"); 7} 8?> 9--FILE-- 10<?php 11/* Prototype : string gmstrftime(string format [, int timestamp]) 12 * Description: Format a GMT/UCT time/date according to locale settings 13 * Source code: ext/date/php_date.c 14 * Alias to functions: 15 */ 16 17echo "*** Testing gmstrftime() : usage variation ***\n"; 18 19date_default_timezone_set("Asia/Calcutta"); 20 21// Initialise function arguments not being substituted (if any) 22$format = '%b %d %Y %H:%M:%S'; 23 24//get an unset variable 25$unset_var = 10; 26unset ($unset_var); 27 28// define some classes 29class classWithToString 30{ 31 public function __toString() { 32 return "Class A object"; 33 } 34} 35 36class classWithoutToString 37{ 38} 39 40// heredoc string 41$heredoc = <<<EOT 42hello world 43EOT; 44 45// add arrays 46$index_array = array (1, 2, 3); 47$assoc_array = array ('one' => 1, 'two' => 2); 48 49//array of values to iterate over 50$inputs = array( 51 52 // float data 53 'float 10.5' => 10.5, 54 'float -10.5' => -10.5, 55 'float 12.3456789000e10' => 12.3456789000e10, 56 'float -12.3456789000e10' => -12.3456789000e10, 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 96// loop through each element of the array for timestamp 97 98foreach($inputs as $key =>$value) { 99 echo "\n--$key--\n"; 100 var_dump( gmstrftime($format, $value) ); 101}; 102 103?> 104===DONE=== 105--EXPECTF-- 106*** Testing gmstrftime() : usage variation *** 107 108--float 10.5-- 109string(20) "Jan 01 1970 00:00:10" 110 111--float -10.5-- 112string(20) "Dec 31 1969 23:59:50" 113 114--float 12.3456789000e10-- 115string(20) "Mar 26 1935 04:50:16" 116 117--float -12.3456789000e10-- 118string(20) "Oct 08 2004 19:09:44" 119 120--float .5-- 121string(20) "Jan 01 1970 00:00:00" 122 123--empty array-- 124 125Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d 126bool(false) 127 128--int indexed array-- 129 130Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d 131bool(false) 132 133--associative array-- 134 135Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d 136bool(false) 137 138--nested arrays-- 139 140Warning: gmstrftime() expects parameter 2 to be long, array given in %s on line %d 141bool(false) 142 143--uppercase NULL-- 144string(20) "Jan 01 1970 00:00:00" 145 146--lowercase null-- 147string(20) "Jan 01 1970 00:00:00" 148 149--lowercase true-- 150string(20) "Jan 01 1970 00:00:01" 151 152--lowercase false-- 153string(20) "Jan 01 1970 00:00:00" 154 155--uppercase TRUE-- 156string(20) "Jan 01 1970 00:00:01" 157 158--uppercase FALSE-- 159string(20) "Jan 01 1970 00:00:00" 160 161--empty string DQ-- 162 163Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d 164bool(false) 165 166--empty string SQ-- 167 168Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d 169bool(false) 170 171--string DQ-- 172 173Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d 174bool(false) 175 176--string SQ-- 177 178Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d 179bool(false) 180 181--mixed case string-- 182 183Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d 184bool(false) 185 186--heredoc-- 187 188Warning: gmstrftime() expects parameter 2 to be long, string given in %s on line %d 189bool(false) 190 191--instance of classWithToString-- 192 193Warning: gmstrftime() expects parameter 2 to be long, object given in %s on line %d 194bool(false) 195 196--instance of classWithoutToString-- 197 198Warning: gmstrftime() expects parameter 2 to be long, object given in %s on line %d 199bool(false) 200 201--undefined var-- 202string(20) "Jan 01 1970 00:00:00" 203 204--unset var-- 205string(20) "Jan 01 1970 00:00:00" 206===DONE=== 207