1--TEST-- 2Test strtolower() function 3--SKIPIF-- 4<?php 5if( substr(PHP_OS, 0, 3) == 'WIN') { 6 if (!setlocale(LC_ALL, 'C')) { 7 die('skip need "C" locale (this windows is broken)'); 8 } 9} else { 10 if (!setlocale(LC_ALL, 'en_US.UTF-8', 'en')) { 11 die('skip need "en_US.UTF-8" locale'); 12 } 13} 14?> 15--FILE-- 16<?php 17/* Prototype: 18 string strtolower ( string $str ); 19 Description: 20 Returns string with all alphabetic characters converted to lowercase. 21*/ 22if( substr(PHP_OS, 0, 3) == 'WIN') { 23 setlocale(LC_ALL, 'C'); 24} else { 25 setlocale(LC_ALL, 'en_US.UTF-8'); 26} 27 28echo "*** Testing strtolower() with all 256 chars ***\n"; 29for ($i=0; $i<=255; $i++){ 30 $char = chr($i); 31 print(bin2hex($char))." => ".(bin2hex(strtolower("$char")))."\n"; 32} 33 34echo "*** Testing strlower() with basic strings ***\n"; 35$str = "Mary Had A liTTle LAmb and ShE loveD IT So\n"; 36var_dump(strtolower($str)); 37 38echo "\n*** Testing strtolower() with various strings ***"; 39/* strings to pass strtolower() */ 40$strings = array ( 41 "", 42 "string", 43 "stRINg0234", 44 "1.233.344StrinG12333", 45 "$$$$$$!!!!@@@@@@@ ABCDEF !!!***", 46 "ABCD\0abcdABCD", 47 NULL, 48 TRUE, 49 FALSE, 50 array() 51); 52 53$count = 0; 54/* loop through to check possible variations */ 55foreach ($strings as $string) { 56 echo "\n-- Iteration $count --\n"; 57 var_dump( strtolower($string) ); 58 $count++; 59} 60 61echo "\n*** Testing strtolower() with two different case strings ***\n"; 62if (strtolower("HeLLo woRLd") === strtolower("hEllo WORLD")) 63 echo "strings are same, with Case Insensitive\n"; 64else 65 echo "strings are not same\n"; 66 67echo "\n*** Testing error conditions ***"; 68var_dump( strtolower() ); /* Zero arguments */ 69var_dump( strtolower("a", "b") ); /* Arguments > Expected */ 70 71echo "*** Done ***"; 72?> 73--EXPECTF-- 74*** Testing strtolower() with all 256 chars *** 7500 => 00 7601 => 01 7702 => 02 7803 => 03 7904 => 04 8005 => 05 8106 => 06 8207 => 07 8308 => 08 8409 => 09 850a => 0a 860b => 0b 870c => 0c 880d => 0d 890e => 0e 900f => 0f 9110 => 10 9211 => 11 9312 => 12 9413 => 13 9514 => 14 9615 => 15 9716 => 16 9817 => 17 9918 => 18 10019 => 19 1011a => 1a 1021b => 1b 1031c => 1c 1041d => 1d 1051e => 1e 1061f => 1f 10720 => 20 10821 => 21 10922 => 22 11023 => 23 11124 => 24 11225 => 25 11326 => 26 11427 => 27 11528 => 28 11629 => 29 1172a => 2a 1182b => 2b 1192c => 2c 1202d => 2d 1212e => 2e 1222f => 2f 12330 => 30 12431 => 31 12532 => 32 12633 => 33 12734 => 34 12835 => 35 12936 => 36 13037 => 37 13138 => 38 13239 => 39 1333a => 3a 1343b => 3b 1353c => 3c 1363d => 3d 1373e => 3e 1383f => 3f 13940 => 40 14041 => 61 14142 => 62 14243 => 63 14344 => 64 14445 => 65 14546 => 66 14647 => 67 14748 => 68 14849 => 69 1494a => 6a 1504b => 6b 1514c => 6c 1524d => 6d 1534e => 6e 1544f => 6f 15550 => 70 15651 => 71 15752 => 72 15853 => 73 15954 => 74 16055 => 75 16156 => 76 16257 => 77 16358 => 78 16459 => 79 1655a => 7a 1665b => 5b 1675c => 5c 1685d => 5d 1695e => 5e 1705f => 5f 17160 => 60 17261 => 61 17362 => 62 17463 => 63 17564 => 64 17665 => 65 17766 => 66 17867 => 67 17968 => 68 18069 => 69 1816a => 6a 1826b => 6b 1836c => 6c 1846d => 6d 1856e => 6e 1866f => 6f 18770 => 70 18871 => 71 18972 => 72 19073 => 73 19174 => 74 19275 => 75 19376 => 76 19477 => 77 19578 => 78 19679 => 79 1977a => 7a 1987b => 7b 1997c => 7c 2007d => 7d 2017e => 7e 2027f => 7f 20380 => 80 20481 => 81 20582 => 82 20683 => 83 20784 => 84 20885 => 85 20986 => 86 21087 => 87 21188 => 88 21289 => 89 2138a => 8a 2148b => 8b 2158c => 8c 2168d => 8d 2178e => 8e 2188f => 8f 21990 => 90 22091 => 91 22192 => 92 22293 => 93 22394 => 94 22495 => 95 22596 => 96 22697 => 97 22798 => 98 22899 => 99 2299a => 9a 2309b => 9b 2319c => 9c 2329d => 9d 2339e => 9e 2349f => 9f 235a0 => a0 236a1 => a1 237a2 => a2 238a3 => a3 239a4 => a4 240a5 => a5 241a6 => a6 242a7 => a7 243a8 => a8 244a9 => a9 245aa => aa 246ab => ab 247ac => ac 248ad => ad 249ae => ae 250af => af 251b0 => b0 252b1 => b1 253b2 => b2 254b3 => b3 255b4 => b4 256b5 => b5 257b6 => b6 258b7 => b7 259b8 => b8 260b9 => b9 261ba => ba 262bb => bb 263bc => bc 264bd => bd 265be => be 266bf => bf 267c0 => c0 268c1 => c1 269c2 => c2 270c3 => c3 271c4 => c4 272c5 => c5 273c6 => c6 274c7 => c7 275c8 => c8 276c9 => c9 277ca => ca 278cb => cb 279cc => cc 280cd => cd 281ce => ce 282cf => cf 283d0 => d0 284d1 => d1 285d2 => d2 286d3 => d3 287d4 => d4 288d5 => d5 289d6 => d6 290d7 => d7 291d8 => d8 292d9 => d9 293da => da 294db => db 295dc => dc 296dd => dd 297de => de 298df => df 299e0 => e0 300e1 => e1 301e2 => e2 302e3 => e3 303e4 => e4 304e5 => e5 305e6 => e6 306e7 => e7 307e8 => e8 308e9 => e9 309ea => ea 310eb => eb 311ec => ec 312ed => ed 313ee => ee 314ef => ef 315f0 => f0 316f1 => f1 317f2 => f2 318f3 => f3 319f4 => f4 320f5 => f5 321f6 => f6 322f7 => f7 323f8 => f8 324f9 => f9 325fa => fa 326fb => fb 327fc => fc 328fd => fd 329fe => fe 330ff => ff 331*** Testing strlower() with basic strings *** 332string(43) "mary had a little lamb and she loved it so 333" 334 335*** Testing strtolower() with various strings *** 336-- Iteration 0 -- 337string(0) "" 338 339-- Iteration 1 -- 340string(6) "string" 341 342-- Iteration 2 -- 343string(10) "string0234" 344 345-- Iteration 3 -- 346string(20) "1.233.344string12333" 347 348-- Iteration 4 -- 349string(31) "$$$$$$!!!!@@@@@@@ abcdef !!!***" 350 351-- Iteration 5 -- 352string(13) "abcdabcdabcd" 353 354-- Iteration 6 -- 355string(0) "" 356 357-- Iteration 7 -- 358string(1) "1" 359 360-- Iteration 8 -- 361string(0) "" 362 363-- Iteration 9 -- 364 365Warning: strtolower() expects parameter 1 to be string, array given in %s on line %d 366NULL 367 368*** Testing strtolower() with two different case strings *** 369strings are same, with Case Insensitive 370 371*** Testing error conditions *** 372Warning: strtolower() expects exactly 1 parameter, 0 given in %s on line %d 373NULL 374 375Warning: strtolower() expects exactly 1 parameter, 2 given in %s on line %d 376NULL 377*** Done *** 378