1--TEST-- 2Test strtoupper() 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 strtoupper() with 128 chars ***\n"; 24for ($i=0; $i<=127; $i++){ 25 $char = chr($i); 26 print(bin2hex($char))." => ".(bin2hex(strtoupper("$char")))."\n"; 27} 28 29echo "\n*** Testing strtoupper() with basic strings ***\n"; 30$str = "Mary Had A liTTle LAmb and ShE loveD IT So\n"; 31var_dump(strtoupper($str)); 32 33echo "\n*** Testing strtoupper() with various strings ***"; 34/* strings to pass strtoupper() */ 35$strings = array ( 36 "", 37 "string", 38 "stRINg0234", 39 "1.233.344StrinG12333", 40 "$$$$$$!!!!@@@@@@@ ABCDEF !!!***", 41 "ABCD\0abcdABCD", 42 TRUE, 43 FALSE, 44); 45 46$count = 0; 47/* loop through to check possible variations */ 48foreach ($strings as $string) { 49 echo "\n-- Iteration $count --\n"; 50 var_dump( strtoupper($string) ); 51 $count++; 52} 53 54echo "\n*** Testing strtoupper() with two different case strings ***\n"; 55if (strtoupper("HeLLo woRLd") === strtoupper("hEllo WORLD")) 56 echo "strings are same, with Case Insensitive\n"; 57else 58 echo "strings are not same\n"; 59 60echo "*** Done ***"; 61?> 62--EXPECTF-- 63*** Testing strtoupper() with 128 chars *** 6400 => 00 6501 => 01 6602 => 02 6703 => 03 6804 => 04 6905 => 05 7006 => 06 7107 => 07 7208 => 08 7309 => 09 740a => 0a 750b => 0b 760c => 0c 770d => 0d 780e => 0e 790f => 0f 8010 => 10 8111 => 11 8212 => 12 8313 => 13 8414 => 14 8515 => 15 8616 => 16 8717 => 17 8818 => 18 8919 => 19 901a => 1a 911b => 1b 921c => 1c 931d => 1d 941e => 1e 951f => 1f 9620 => 20 9721 => 21 9822 => 22 9923 => 23 10024 => 24 10125 => 25 10226 => 26 10327 => 27 10428 => 28 10529 => 29 1062a => 2a 1072b => 2b 1082c => 2c 1092d => 2d 1102e => 2e 1112f => 2f 11230 => 30 11331 => 31 11432 => 32 11533 => 33 11634 => 34 11735 => 35 11836 => 36 11937 => 37 12038 => 38 12139 => 39 1223a => 3a 1233b => 3b 1243c => 3c 1253d => 3d 1263e => 3e 1273f => 3f 12840 => 40 12941 => 41 13042 => 42 13143 => 43 13244 => 44 13345 => 45 13446 => 46 13547 => 47 13648 => 48 13749 => 49 1384a => 4a 1394b => 4b 1404c => 4c 1414d => 4d 1424e => 4e 1434f => 4f 14450 => 50 14551 => 51 14652 => 52 14753 => 53 14854 => 54 14955 => 55 15056 => 56 15157 => 57 15258 => 58 15359 => 59 1545a => 5a 1555b => 5b 1565c => 5c 1575d => 5d 1585e => 5e 1595f => 5f 16060 => 60 16161 => 41 16262 => 42 16363 => 43 16464 => 44 16565 => 45 16666 => 46 16767 => 47 16868 => 48 16969 => 49 1706a => 4a 1716b => 4b 1726c => 4c 1736d => 4d 1746e => 4e 1756f => 4f 17670 => 50 17771 => 51 17872 => 52 17973 => 53 18074 => 54 18175 => 55 18276 => 56 18377 => 57 18478 => 58 18579 => 59 1867a => 5a 1877b => 7b 1887c => 7c 1897d => 7d 1907e => 7e 1917f => 7f 192 193*** Testing strtoupper() with basic strings *** 194string(43) "MARY HAD A LITTLE LAMB AND SHE LOVED IT SO 195" 196 197*** Testing strtoupper() 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) "ABCD%0ABCDABCD" 215 216-- Iteration 6 -- 217string(1) "1" 218 219-- Iteration 7 -- 220string(0) "" 221 222*** Testing strtoupper() with two different case strings *** 223strings are same, with Case Insensitive 224*** Done *** 225