2 Test strtoupper() function
5 if( substr(PHP_OS, 0, 3) == 'WIN') {
6 if (!setlocale(LC_ALL, 'C')) {
7 die('skip need "C" locale (this windows is broken)');
10 if (!setlocale(LC_ALL, 'en_US.UTF-8', 'en')) {
11 die('skip need "en_US.UTF-8" locale');
18 string strtoupper ( string $string );
20 Returns string with all alphabetic characters converted to uppercase
22 if( substr(PHP_OS, 0, 3) == 'WIN') {
23 setlocale(LC_ALL, 'C');
25 setlocale(LC_ALL, 'en_US.UTF-8');
28 echo "*** Testing strtoupper() with 128 chars ***\n";
29 for ($i=0; $i<=127; $i++){
31 print(bin2hex($char))." => ".(bin2hex(strtoupper("$char")))."\n";
34 echo "\n*** Testing strtoupper() with basic strings ***\n";
35 $str = "Mary Had A liTTle LAmb and ShE loveD IT So\n";
36 var_dump(strtoupper($str));
38 echo "\n*** Testing strtoupper() with various strings ***";
39 /* strings to pass strtoupper() */
44 "1.233.344StrinG12333",
45 "$$$$$$!!!!@@@@@@@ ABCDEF !!!***",
53 /* loop through to check possible variations */
54 foreach ($strings as $string) {
55 echo "\n-- Iteration $count --\n";
56 var_dump( strtoupper($string) );
60 echo "\n*** Testing strtoupper() with two different case strings ***\n";
61 if (strtoupper("HeLLo woRLd") === strtoupper("hEllo WORLD"))
62 echo "strings are same, with Case Insensitive\n";
64 echo "strings are not same\n";
69 *** Testing strtoupper() with 128 chars ***
199 *** Testing strtoupper() with basic strings ***
200 string(43) "MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
203 *** Testing strtoupper() with various strings ***
211 string(10) "STRING0234"
214 string(20) "1.233.344STRING12333"
217 string(31) "$$$$$$!!!!@@@@@@@ ABCDEF !!!***"
220 string(13) "ABCD
\0ABCDABCD"
231 *** Testing strtoupper() with two different case strings ***
232 strings are same, with Case Insensitive