1--TEST--
2Test strncasecmp() function: usage variations - case-sensitivity
3--FILE--
4<?php
5/* Prototype  : int strncasecmp ( string $str1, string $str2, int $len );
6 * Description: Binary safe case-insensitive string comparison of the first n characters
7 * Source code: Zend/zend_builtin_functions.c
8*/
9
10/* Test strncasecmp() function with upper-case and lower-case alphabets as inputs for 'str1' and 'str2' */
11
12echo "*** Test strncasecmp() function: with alphabets ***\n";
13echo "-- Passing upper-case letters for 'str1' --\n";
14for($ASCII = 65; $ASCII <= 90; $ASCII++) {
15  var_dump( strncasecmp( chr($ASCII), chr($ASCII), 1 ) );  //comparing uppercase letter with corresponding uppercase letter; exp: int(0)
16  var_dump( strncasecmp( chr($ASCII), chr($ASCII + 32), 1 ) );  //comparing uppercase letter with corresponding lowercase letter; exp: int(0)
17}
18
19echo "\n-- Passing lower-case letters for 'str1' --\n";
20for($ASCII = 97; $ASCII <= 122; $ASCII++) {
21  var_dump( strncasecmp( chr($ASCII), chr($ASCII), 1 ) );  //comparing lowercase letter with corresponding lowercase letter; exp: int(0)
22  var_dump( strncasecmp( chr($ASCII), chr($ASCII - 32), 1 ) );  //comparing lowercase letter with corresponding uppercase letter; exp: int(0)
23}
24echo "*** Done ***\n";
25?>
26--EXPECT--
27*** Test strncasecmp() function: with alphabets ***
28-- Passing upper-case letters for 'str1' --
29int(0)
30int(0)
31int(0)
32int(0)
33int(0)
34int(0)
35int(0)
36int(0)
37int(0)
38int(0)
39int(0)
40int(0)
41int(0)
42int(0)
43int(0)
44int(0)
45int(0)
46int(0)
47int(0)
48int(0)
49int(0)
50int(0)
51int(0)
52int(0)
53int(0)
54int(0)
55int(0)
56int(0)
57int(0)
58int(0)
59int(0)
60int(0)
61int(0)
62int(0)
63int(0)
64int(0)
65int(0)
66int(0)
67int(0)
68int(0)
69int(0)
70int(0)
71int(0)
72int(0)
73int(0)
74int(0)
75int(0)
76int(0)
77int(0)
78int(0)
79int(0)
80int(0)
81
82-- Passing lower-case letters for 'str1' --
83int(0)
84int(0)
85int(0)
86int(0)
87int(0)
88int(0)
89int(0)
90int(0)
91int(0)
92int(0)
93int(0)
94int(0)
95int(0)
96int(0)
97int(0)
98int(0)
99int(0)
100int(0)
101int(0)
102int(0)
103int(0)
104int(0)
105int(0)
106int(0)
107int(0)
108int(0)
109int(0)
110int(0)
111int(0)
112int(0)
113int(0)
114int(0)
115int(0)
116int(0)
117int(0)
118int(0)
119int(0)
120int(0)
121int(0)
122int(0)
123int(0)
124int(0)
125int(0)
126int(0)
127int(0)
128int(0)
129int(0)
130int(0)
131int(0)
132int(0)
133int(0)
134int(0)
135*** Done ***
136