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 as "English_United States.1252"');
7?>
8--FILE--
9<?php
10/* Prototype:
11     string strtolower ( string $str );
12   Description:
13     Returns string with all alphabetic characters converted to lowercase.
14*/
15
16echo "*** Testing strtolower() with all 256 chars ***\n";
17for ($i=0; $i<=255; $i++){
18  $char = chr($i);
19  print(bin2hex($char))." => ".(bin2hex(strtolower("$char")))."\n";
20}
21
22echo "*** Testing strlower() with basic strings ***\n";
23$str = "Mary Had A liTTle LAmb and ShE loveD IT So\n";
24var_dump(strtolower($str));
25
26echo "\n*** Testing strtolower() with various strings ***";
27/* strings to pass strtolower() */
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( strtolower($string) );
46  $count++;
47}
48
49echo "\n*** Testing strtolower() with two different case strings ***\n";
50if (strtolower("HeLLo woRLd") === strtolower("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( strtolower() ); /* Zero arguments */
57var_dump( strtolower("a", "b") ); /* Arguments > Expected */
58
59echo "*** Done ***";
60?>
61--EXPECTF--
62*** Testing strtolower() 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 => 61
12942 => 62
13043 => 63
13144 => 64
13245 => 65
13346 => 66
13447 => 67
13548 => 68
13649 => 69
1374a => 6a
1384b => 6b
1394c => 6c
1404d => 6d
1414e => 6e
1424f => 6f
14350 => 70
14451 => 71
14552 => 72
14653 => 73
14754 => 74
14855 => 75
14956 => 76
15057 => 77
15158 => 78
15259 => 79
1535a => 7a
1545b => 5b
1555c => 5c
1565d => 5d
1575e => 5e
1585f => 5f
15960 => 60
16061 => 61
16162 => 62
16263 => 63
16364 => 64
16465 => 65
16566 => 66
16667 => 67
16768 => 68
16869 => 69
1696a => 6a
1706b => 6b
1716c => 6c
1726d => 6d
1736e => 6e
1746f => 6f
17570 => 70
17671 => 71
17772 => 72
17873 => 73
17974 => 74
18075 => 75
18176 => 76
18277 => 77
18378 => 78
18479 => 79
1857a => 7a
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 => 9a
2028b => 8b
2038c => 9c
2048d => 8d
2058e => 9e
2068f => 8f
20790 => 90
20891 => 91
20992 => 92
21093 => 93
21194 => 94
21295 => 95
21396 => 96
21497 => 97
21598 => 98
21699 => 99
2179a => 9a
2189b => 9b
2199c => 9c
2209d => 9d
2219e => 9e
2229f => ff
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 => e0
256c1 => e1
257c2 => e2
258c3 => e3
259c4 => e4
260c5 => e5
261c6 => e6
262c7 => e7
263c8 => e8
264c9 => e9
265ca => ea
266cb => eb
267cc => ec
268cd => ed
269ce => ee
270cf => ef
271d0 => f0
272d1 => f1
273d2 => f2
274d3 => f3
275d4 => f4
276d5 => f5
277d6 => f6
278d7 => d7
279d8 => f8
280d9 => f9
281da => fa
282db => fb
283dc => fc
284dd => fd
285de => fe
286df => df
287e0 => e0
288e1 => e1
289e2 => e2
290e3 => e3
291e4 => e4
292e5 => e5
293e6 => e6
294e7 => e7
295e8 => e8
296e9 => e9
297ea => ea
298eb => eb
299ec => ec
300ed => ed
301ee => ee
302ef => ef
303f0 => f0
304f1 => f1
305f2 => f2
306f3 => f3
307f4 => f4
308f5 => f5
309f6 => f6
310f7 => f7
311f8 => f8
312f9 => f9
313fa => fa
314fb => fb
315fc => fc
316fd => fd
317fe => fe
318ff => ff
319*** Testing strlower() with basic strings ***
320string(43) "mary had a little lamb and she loved it so
321"
322
323*** Testing strtolower() with various strings ***
324-- Iteration 0 --
325string(0) ""
326
327-- Iteration 1 --
328string(6) "string"
329
330-- Iteration 2 --
331string(10) "string0234"
332
333-- Iteration 3 --
334string(20) "1.233.344string12333"
335
336-- Iteration 4 --
337string(31) "$$$$$$!!!!@@@@@@@ abcdef !!!***"
338
339-- Iteration 5 --
340string(13) "abcd�abcdabcd"
341
342-- Iteration 6 --
343string(0) ""
344
345-- Iteration 7 --
346string(1) "1"
347
348-- Iteration 8 --
349string(0) ""
350
351-- Iteration 9 --
352
353Warning: strtolower() expects parameter 1 to be string, array given in %s on line %d
354NULL
355
356*** Testing strtolower() with two different case strings ***
357strings are same, with Case Insensitive
358
359*** Testing error conditions ***
360Warning: strtolower() expects exactly 1 parameter, 0 given in %s on line %d
361NULL
362
363Warning: strtolower() expects exactly 1 parameter, 2 given in %s on line %d
364NULL
365*** Done ***
366