1--TEST--
2Test strtolower() 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 "English_United States.1252" available');
7?>
8--FILE--
9<?php
10setlocale(LC_CTYPE, "English_United States.1252");
11
12echo "*** Testing strtolower() with all 256 chars ***\n";
13for ($i=0; $i<=255; $i++){
14  $char = chr($i);
15  print(bin2hex($char))." => ".(bin2hex(strtolower("$char")))."\n";
16}
17
18echo "*** Testing strlower() with basic strings ***\n";
19$str = "Mary Had A liTTle LAmb and ShE loveD IT So\n";
20var_dump(strtolower($str));
21
22echo "\n*** Testing strtolower() with various strings ***";
23/* strings to pass strtolower() */
24$strings = array (
25  "",
26  "string",
27  "stRINg0234",
28  "1.233.344StrinG12333",
29  "$$$$$$!!!!@@@@@@@ ABCDEF !!!***",
30  "ABCD\0abcdABCD",
31  NULL,
32  TRUE,
33  FALSE,
34);
35
36$count = 0;
37/* loop through to check possible variations */
38foreach ($strings as $string) {
39  echo "\n-- Iteration $count --\n";
40  var_dump( strtolower($string) );
41  $count++;
42}
43
44echo "\n*** Testing strtolower() with two different case strings ***\n";
45if (strtolower("HeLLo woRLd") === strtolower("hEllo WORLD"))
46  echo "strings are same, with Case Insensitive\n";
47else
48  echo "strings are not same\n";
49
50echo "*** Done ***";
51?>
52--EXPECT--
53*** Testing strtolower() with all 256 chars ***
5400 => 00
5501 => 01
5602 => 02
5703 => 03
5804 => 04
5905 => 05
6006 => 06
6107 => 07
6208 => 08
6309 => 09
640a => 0a
650b => 0b
660c => 0c
670d => 0d
680e => 0e
690f => 0f
7010 => 10
7111 => 11
7212 => 12
7313 => 13
7414 => 14
7515 => 15
7616 => 16
7717 => 17
7818 => 18
7919 => 19
801a => 1a
811b => 1b
821c => 1c
831d => 1d
841e => 1e
851f => 1f
8620 => 20
8721 => 21
8822 => 22
8923 => 23
9024 => 24
9125 => 25
9226 => 26
9327 => 27
9428 => 28
9529 => 29
962a => 2a
972b => 2b
982c => 2c
992d => 2d
1002e => 2e
1012f => 2f
10230 => 30
10331 => 31
10432 => 32
10533 => 33
10634 => 34
10735 => 35
10836 => 36
10937 => 37
11038 => 38
11139 => 39
1123a => 3a
1133b => 3b
1143c => 3c
1153d => 3d
1163e => 3e
1173f => 3f
11840 => 40
11941 => 61
12042 => 62
12143 => 63
12244 => 64
12345 => 65
12446 => 66
12547 => 67
12648 => 68
12749 => 69
1284a => 6a
1294b => 6b
1304c => 6c
1314d => 6d
1324e => 6e
1334f => 6f
13450 => 70
13551 => 71
13652 => 72
13753 => 73
13854 => 74
13955 => 75
14056 => 76
14157 => 77
14258 => 78
14359 => 79
1445a => 7a
1455b => 5b
1465c => 5c
1475d => 5d
1485e => 5e
1495f => 5f
15060 => 60
15161 => 61
15262 => 62
15363 => 63
15464 => 64
15565 => 65
15666 => 66
15767 => 67
15868 => 68
15969 => 69
1606a => 6a
1616b => 6b
1626c => 6c
1636d => 6d
1646e => 6e
1656f => 6f
16670 => 70
16771 => 71
16872 => 72
16973 => 73
17074 => 74
17175 => 75
17276 => 76
17377 => 77
17478 => 78
17579 => 79
1767a => 7a
1777b => 7b
1787c => 7c
1797d => 7d
1807e => 7e
1817f => 7f
18280 => 80
18381 => 81
18482 => 82
18583 => 83
18684 => 84
18785 => 85
18886 => 86
18987 => 87
19088 => 88
19189 => 89
1928a => 9a
1938b => 8b
1948c => 9c
1958d => 8d
1968e => 9e
1978f => 8f
19890 => 90
19991 => 91
20092 => 92
20193 => 93
20294 => 94
20395 => 95
20496 => 96
20597 => 97
20698 => 98
20799 => 99
2089a => 9a
2099b => 9b
2109c => 9c
2119d => 9d
2129e => 9e
2139f => ff
214a0 => a0
215a1 => a1
216a2 => a2
217a3 => a3
218a4 => a4
219a5 => a5
220a6 => a6
221a7 => a7
222a8 => a8
223a9 => a9
224aa => aa
225ab => ab
226ac => ac
227ad => ad
228ae => ae
229af => af
230b0 => b0
231b1 => b1
232b2 => b2
233b3 => b3
234b4 => b4
235b5 => b5
236b6 => b6
237b7 => b7
238b8 => b8
239b9 => b9
240ba => ba
241bb => bb
242bc => bc
243bd => bd
244be => be
245bf => bf
246c0 => e0
247c1 => e1
248c2 => e2
249c3 => e3
250c4 => e4
251c5 => e5
252c6 => e6
253c7 => e7
254c8 => e8
255c9 => e9
256ca => ea
257cb => eb
258cc => ec
259cd => ed
260ce => ee
261cf => ef
262d0 => f0
263d1 => f1
264d2 => f2
265d3 => f3
266d4 => f4
267d5 => f5
268d6 => f6
269d7 => d7
270d8 => f8
271d9 => f9
272da => fa
273db => fb
274dc => fc
275dd => fd
276de => fe
277df => df
278e0 => e0
279e1 => e1
280e2 => e2
281e3 => e3
282e4 => e4
283e5 => e5
284e6 => e6
285e7 => e7
286e8 => e8
287e9 => e9
288ea => ea
289eb => eb
290ec => ec
291ed => ed
292ee => ee
293ef => ef
294f0 => f0
295f1 => f1
296f2 => f2
297f3 => f3
298f4 => f4
299f5 => f5
300f6 => f6
301f7 => f7
302f8 => f8
303f9 => f9
304fa => fa
305fb => fb
306fc => fc
307fd => fd
308fe => fe
309ff => ff
310*** Testing strlower() with basic strings ***
311string(43) "mary had a little lamb and she loved it so
312"
313
314*** Testing strtolower() with various strings ***
315-- Iteration 0 --
316string(0) ""
317
318-- Iteration 1 --
319string(6) "string"
320
321-- Iteration 2 --
322string(10) "string0234"
323
324-- Iteration 3 --
325string(20) "1.233.344string12333"
326
327-- Iteration 4 --
328string(31) "$$$$$$!!!!@@@@@@@ abcdef !!!***"
329
330-- Iteration 5 --
331string(13) "abcd�abcdabcd"
332
333-- Iteration 6 --
334string(0) ""
335
336-- Iteration 7 --
337string(1) "1"
338
339-- Iteration 8 --
340string(0) ""
341
342*** Testing strtolower() with two different case strings ***
343strings are same, with Case Insensitive
344*** Done ***
345