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 17if( substr(PHP_OS, 0, 3) == 'WIN') { 18 setlocale(LC_ALL, 'C'); 19} else { 20 setlocale(LC_ALL, 'en_US.UTF-8'); 21} 22 23echo "*** Testing strtolower() with 128 chars ***\n"; 24for ($i=0; $i<=127; $i++){ 25 $char = chr($i); 26 print(bin2hex($char))." => ".(bin2hex(strtolower("$char")))."\n"; 27} 28 29echo "*** Testing strlower() with basic strings ***\n"; 30$str = "Mary Had A liTTle LAmb and ShE loveD IT So\n"; 31var_dump(strtolower($str)); 32 33echo "\n*** Testing strtolower() with various strings ***"; 34/* strings to pass strtolower() */ 35$strings = array ( 36 "", 37 "string", 38 "stRINg0234", 39 "1.233.344StrinG12333", 40 "$$$$$$!!!!@@@@@@@ ABCDEF !!!***", 41 "ABCD\0abcdABCD", 42 NULL, 43 TRUE, 44 FALSE, 45); 46 47$count = 0; 48/* loop through to check possible variations */ 49foreach ($strings as $string) { 50 echo "\n-- Iteration $count --\n"; 51 var_dump( strtolower($string) ); 52 $count++; 53} 54 55echo "\n*** Testing strtolower() with two different case strings ***\n"; 56if (strtolower("HeLLo woRLd") === strtolower("hEllo WORLD")) 57 echo "strings are same, with Case Insensitive\n"; 58else 59 echo "strings are not same\n"; 60 61echo "*** Done ***"; 62?> 63--EXPECT-- 64*** Testing strtolower() with 128 chars *** 6500 => 00 6601 => 01 6702 => 02 6803 => 03 6904 => 04 7005 => 05 7106 => 06 7207 => 07 7308 => 08 7409 => 09 750a => 0a 760b => 0b 770c => 0c 780d => 0d 790e => 0e 800f => 0f 8110 => 10 8211 => 11 8312 => 12 8413 => 13 8514 => 14 8615 => 15 8716 => 16 8817 => 17 8918 => 18 9019 => 19 911a => 1a 921b => 1b 931c => 1c 941d => 1d 951e => 1e 961f => 1f 9720 => 20 9821 => 21 9922 => 22 10023 => 23 10124 => 24 10225 => 25 10326 => 26 10427 => 27 10528 => 28 10629 => 29 1072a => 2a 1082b => 2b 1092c => 2c 1102d => 2d 1112e => 2e 1122f => 2f 11330 => 30 11431 => 31 11532 => 32 11633 => 33 11734 => 34 11835 => 35 11936 => 36 12037 => 37 12138 => 38 12239 => 39 1233a => 3a 1243b => 3b 1253c => 3c 1263d => 3d 1273e => 3e 1283f => 3f 12940 => 40 13041 => 61 13142 => 62 13243 => 63 13344 => 64 13445 => 65 13546 => 66 13647 => 67 13748 => 68 13849 => 69 1394a => 6a 1404b => 6b 1414c => 6c 1424d => 6d 1434e => 6e 1444f => 6f 14550 => 70 14651 => 71 14752 => 72 14853 => 73 14954 => 74 15055 => 75 15156 => 76 15257 => 77 15358 => 78 15459 => 79 1555a => 7a 1565b => 5b 1575c => 5c 1585d => 5d 1595e => 5e 1605f => 5f 16160 => 60 16261 => 61 16362 => 62 16463 => 63 16564 => 64 16665 => 65 16766 => 66 16867 => 67 16968 => 68 17069 => 69 1716a => 6a 1726b => 6b 1736c => 6c 1746d => 6d 1756e => 6e 1766f => 6f 17770 => 70 17871 => 71 17972 => 72 18073 => 73 18174 => 74 18275 => 75 18376 => 76 18477 => 77 18578 => 78 18679 => 79 1877a => 7a 1887b => 7b 1897c => 7c 1907d => 7d 1917e => 7e 1927f => 7f 193*** Testing strlower() with basic strings *** 194string(43) "mary had a little lamb and she loved it so 195" 196 197*** Testing strtolower() with various strings *** 198-- Iteration 0 -- 199string(0) "" 200 201-- Iteration 1 -- 202string(6) "string" 203 204-- Iteration 2 -- 205string(10) "string0234" 206 207-- Iteration 3 -- 208string(20) "1.233.344string12333" 209 210-- Iteration 4 -- 211string(31) "$$$$$$!!!!@@@@@@@ abcdef !!!***" 212 213-- Iteration 5 -- 214string(13) "abcdabcdabcd" 215 216-- Iteration 6 -- 217string(0) "" 218 219-- Iteration 7 -- 220string(1) "1" 221 222-- Iteration 8 -- 223string(0) "" 224 225*** Testing strtolower() with two different case strings *** 226strings are same, with Case Insensitive 227*** Done *** 228