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  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( strtolower($string) );
51  $count++;
52}
53
54echo "\n*** Testing strtolower() with two different case strings ***\n";
55if (strtolower("HeLLo woRLd") === strtolower("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 strtolower() 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 => 61
13042 => 62
13143 => 63
13244 => 64
13345 => 65
13446 => 66
13547 => 67
13648 => 68
13749 => 69
1384a => 6a
1394b => 6b
1404c => 6c
1414d => 6d
1424e => 6e
1434f => 6f
14450 => 70
14551 => 71
14652 => 72
14753 => 73
14854 => 74
14955 => 75
15056 => 76
15157 => 77
15258 => 78
15359 => 79
1545a => 7a
1555b => 5b
1565c => 5c
1575d => 5d
1585e => 5e
1595f => 5f
16060 => 60
16161 => 61
16262 => 62
16363 => 63
16464 => 64
16565 => 65
16666 => 66
16767 => 67
16868 => 68
16969 => 69
1706a => 6a
1716b => 6b
1726c => 6c
1736d => 6d
1746e => 6e
1756f => 6f
17670 => 70
17771 => 71
17872 => 72
17973 => 73
18074 => 74
18175 => 75
18276 => 76
18377 => 77
18478 => 78
18579 => 79
1867a => 7a
1877b => 7b
1887c => 7c
1897d => 7d
1907e => 7e
1917f => 7f
192*** Testing strlower() with basic strings ***
193string(43) "mary had a little lamb and she loved it so
194"
195
196*** Testing strtolower() with various strings ***
197-- Iteration 0 --
198string(0) ""
199
200-- Iteration 1 --
201string(6) "string"
202
203-- Iteration 2 --
204string(10) "string0234"
205
206-- Iteration 3 --
207string(20) "1.233.344string12333"
208
209-- Iteration 4 --
210string(31) "$$$$$$!!!!@@@@@@@ abcdef !!!***"
211
212-- Iteration 5 --
213string(13) "abcd%0abcdabcd"
214
215-- Iteration 6 --
216string(1) "1"
217
218-- Iteration 7 --
219string(0) ""
220
221*** Testing strtolower() with two different case strings ***
222strings are same, with Case Insensitive
223*** Done ***
224