1--TEST-- 2Test strtoupper() function 3--SKIPIF-- 4<?php 5if( (substr(PHP_OS, 0, 3) != "WIN") || (setlocale(LC_CTYPE, "") != "English_United States.1252") ) 6 die('skip Run only on Windows with locale as "English_United States.1252"'); 7?> 8--FILE-- 9<?php 10/* Prototype: 11 string strtoupper ( string $string ); 12 Description: 13 Returns string with all alphabetic characters converted to uppercase 14*/ 15 16echo "*** Testing strtoupper() with all 256 chars ***\n"; 17for ($i=0; $i<=255; $i++){ 18 $char = chr($i); 19 print(bin2hex($char))." => ".(bin2hex(strtoupper("$char")))."\n"; 20} 21 22echo "\n*** Testing strtoupper() with basic strings ***\n"; 23$str = "Mary Had A liTTle LAmb and ShE loveD IT So\n"; 24var_dump(strtoupper($str)); 25 26echo "\n*** Testing strtoupper() with various strings ***"; 27/* strings to pass strtoupper() */ 28$strings = array ( 29 "", 30 "string", 31 "stRINg0234", 32 "1.233.344StrinG12333", 33 "$$$$$$!!!!@@@@@@@ ABCDEF !!!***", 34 "ABCD\0abcdABCD", 35 NULL, 36 TRUE, 37 FALSE, 38 array() 39); 40 41$count = 0; 42/* loop through to check possible variations */ 43foreach ($strings as $string) { 44 echo "\n-- Iteration $count --\n"; 45 var_dump( strtoupper($string) ); 46 $count++; 47} 48 49echo "\n*** Testing strtoupper() with two different case strings ***\n"; 50if (strtoupper("HeLLo woRLd") === strtoupper("hEllo WORLD")) 51 echo "strings are same, with Case Insensitive\n"; 52else 53 echo "strings are not same\n"; 54 55echo "\n*** Testing error conditions ***"; 56var_dump( strtoupper() ); /* Zero arguments */ 57var_dump( strtoupper("a", "b") ); /* Arguments > Expected */ 58 59echo "*** Done ***"; 60?> 61--EXPECTF-- 62*** Testing strtoupper() with all 256 chars *** 6300 => 00 6401 => 01 6502 => 02 6603 => 03 6704 => 04 6805 => 05 6906 => 06 7007 => 07 7108 => 08 7209 => 09 730a => 0a 740b => 0b 750c => 0c 760d => 0d 770e => 0e 780f => 0f 7910 => 10 8011 => 11 8112 => 12 8213 => 13 8314 => 14 8415 => 15 8516 => 16 8617 => 17 8718 => 18 8819 => 19 891a => 1a 901b => 1b 911c => 1c 921d => 1d 931e => 1e 941f => 1f 9520 => 20 9621 => 21 9722 => 22 9823 => 23 9924 => 24 10025 => 25 10126 => 26 10227 => 27 10328 => 28 10429 => 29 1052a => 2a 1062b => 2b 1072c => 2c 1082d => 2d 1092e => 2e 1102f => 2f 11130 => 30 11231 => 31 11332 => 32 11433 => 33 11534 => 34 11635 => 35 11736 => 36 11837 => 37 11938 => 38 12039 => 39 1213a => 3a 1223b => 3b 1233c => 3c 1243d => 3d 1253e => 3e 1263f => 3f 12740 => 40 12841 => 41 12942 => 42 13043 => 43 13144 => 44 13245 => 45 13346 => 46 13447 => 47 13548 => 48 13649 => 49 1374a => 4a 1384b => 4b 1394c => 4c 1404d => 4d 1414e => 4e 1424f => 4f 14350 => 50 14451 => 51 14552 => 52 14653 => 53 14754 => 54 14855 => 55 14956 => 56 15057 => 57 15158 => 58 15259 => 59 1535a => 5a 1545b => 5b 1555c => 5c 1565d => 5d 1575e => 5e 1585f => 5f 15960 => 60 16061 => 41 16162 => 42 16263 => 43 16364 => 44 16465 => 45 16566 => 46 16667 => 47 16768 => 48 16869 => 49 1696a => 4a 1706b => 4b 1716c => 4c 1726d => 4d 1736e => 4e 1746f => 4f 17570 => 50 17671 => 51 17772 => 52 17873 => 53 17974 => 54 18075 => 55 18176 => 56 18277 => 57 18378 => 58 18479 => 59 1857a => 5a 1867b => 7b 1877c => 7c 1887d => 7d 1897e => 7e 1907f => 7f 19180 => 80 19281 => 81 19382 => 82 19483 => 83 19584 => 84 19685 => 85 19786 => 86 19887 => 87 19988 => 88 20089 => 89 2018a => 8a 2028b => 8b 2038c => 8c 2048d => 8d 2058e => 8e 2068f => 8f 20790 => 90 20891 => 91 20992 => 92 21093 => 93 21194 => 94 21295 => 95 21396 => 96 21497 => 97 21598 => 98 21699 => 99 2179a => 8a 2189b => 9b 2199c => 8c 2209d => 9d 2219e => 8e 2229f => 9f 223a0 => a0 224a1 => a1 225a2 => a2 226a3 => a3 227a4 => a4 228a5 => a5 229a6 => a6 230a7 => a7 231a8 => a8 232a9 => a9 233aa => aa 234ab => ab 235ac => ac 236ad => ad 237ae => ae 238af => af 239b0 => b0 240b1 => b1 241b2 => b2 242b3 => b3 243b4 => b4 244b5 => b5 245b6 => b6 246b7 => b7 247b8 => b8 248b9 => b9 249ba => ba 250bb => bb 251bc => bc 252bd => bd 253be => be 254bf => bf 255c0 => c0 256c1 => c1 257c2 => c2 258c3 => c3 259c4 => c4 260c5 => c5 261c6 => c6 262c7 => c7 263c8 => c8 264c9 => c9 265ca => ca 266cb => cb 267cc => cc 268cd => cd 269ce => ce 270cf => cf 271d0 => d0 272d1 => d1 273d2 => d2 274d3 => d3 275d4 => d4 276d5 => d5 277d6 => d6 278d7 => d7 279d8 => d8 280d9 => d9 281da => da 282db => db 283dc => dc 284dd => dd 285de => de 286df => df 287e0 => c0 288e1 => c1 289e2 => c2 290e3 => c3 291e4 => c4 292e5 => c5 293e6 => c6 294e7 => c7 295e8 => c8 296e9 => c9 297ea => ca 298eb => cb 299ec => cc 300ed => cd 301ee => ce 302ef => cf 303f0 => d0 304f1 => d1 305f2 => d2 306f3 => d3 307f4 => d4 308f5 => d5 309f6 => d6 310f7 => f7 311f8 => d8 312f9 => d9 313fa => da 314fb => db 315fc => dc 316fd => dd 317fe => de 318ff => 9f 319 320*** Testing strtoupper() with basic strings *** 321string(43) "MARY HAD A LITTLE LAMB AND SHE LOVED IT SO 322" 323 324*** Testing strtoupper() with various strings *** 325-- Iteration 0 -- 326string(0) "" 327 328-- Iteration 1 -- 329string(6) "STRING" 330 331-- Iteration 2 -- 332string(10) "STRING0234" 333 334-- Iteration 3 -- 335string(20) "1.233.344STRING12333" 336 337-- Iteration 4 -- 338string(31) "$$$$$$!!!!@@@@@@@ ABCDEF !!!***" 339 340-- Iteration 5 -- 341string(13) "ABCDABCDABCD" 342 343-- Iteration 6 -- 344string(0) "" 345 346-- Iteration 7 -- 347string(1) "1" 348 349-- Iteration 8 -- 350string(0) "" 351 352-- Iteration 9 -- 353 354Warning: strtoupper() expects parameter 1 to be string, array given in %s on line %d 355NULL 356 357*** Testing strtoupper() with two different case strings *** 358strings are same, with Case Insensitive 359 360*** Testing error conditions *** 361Warning: strtoupper() expects exactly 1 parameter, 0 given in %s on line %d 362NULL 363 364Warning: strtoupper() expects exactly 1 parameter, 2 given in %s on line %d 365NULL 366*** Done *** 367