1--TEST--
2Test stripos() function : usage variations - double quoted strings for 'haystack' & 'needle' arguments
3--FILE--
4<?php
5/* Test stripos() function by passing double quoted strings for 'haystack' & 'needle' arguments */
6
7echo "*** Testing stripos() function: with double quoted strings ***\n";
8$haystack = "Hello,\t\n\0\n  $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 ";
9$needle = array(
10  //regular strings
11  "l",
12  "L",
13  "HELLO",
14  "hEllo",
15
16  //escape characters
17  "\t",
18  "\T",  //invalid input
19  "     ",
20  "\n",
21  "\N",  //invalid input
22  "
23",  //new line
24
25  //nulls
26  "\0",
27  NULL,
28  null,
29
30  //boolean false
31  FALSE,
32  false,
33
34  //empty string
35  "",
36
37  //special chars
38  " ",
39  "$",
40  " $",
41  "&",
42  "!#",
43  "%\o",
44  "\o,",
45  "()",
46  "*+",
47  "+",
48  "-",
49  ".",
50  ".;",
51  ":;",
52  ";",
53  "<=>",
54  ">",
55  "=>",
56  "?",
57  "@",
58  "@hEllo",
59
60  "12345", //decimal numeric string
61  "\x23",  //hexadecimal numeric string
62  "#",  //respective ASCII char of \x23
63  "\101",  //octal numeric string
64  "A",  //respective ASCII char of \101
65  "456HEE",  //numerics + chars
66  $haystack  //haystack as needle
67);
68
69/* loop through to get the position of the needle in haystack string */
70$count = 1;
71for($index=0; $index<count($needle); $index++) {
72  echo "-- Iteration $count --\n";
73  var_dump( stripos($haystack, $needle[$index]) );
74  var_dump( stripos($haystack, $needle[$index], $index) );
75  $count++;
76}
77echo "*** Done ***";
78?>
79--EXPECT--
80*** Testing stripos() function: with double quoted strings ***
81-- Iteration 1 --
82int(2)
83int(2)
84-- Iteration 2 --
85int(2)
86int(2)
87-- Iteration 3 --
88int(0)
89int(34)
90-- Iteration 4 --
91int(0)
92int(34)
93-- Iteration 5 --
94int(6)
95int(6)
96-- Iteration 6 --
97bool(false)
98bool(false)
99-- Iteration 7 --
100bool(false)
101bool(false)
102-- Iteration 8 --
103int(7)
104int(7)
105-- Iteration 9 --
106bool(false)
107bool(false)
108-- Iteration 10 --
109int(7)
110int(9)
111-- Iteration 11 --
112int(8)
113bool(false)
114-- Iteration 12 --
115int(0)
116int(11)
117-- Iteration 13 --
118int(0)
119int(12)
120-- Iteration 14 --
121int(0)
122int(13)
123-- Iteration 15 --
124int(0)
125int(14)
126-- Iteration 16 --
127int(0)
128int(15)
129-- Iteration 17 --
130int(10)
131int(47)
132-- Iteration 18 --
133int(12)
134bool(false)
135-- Iteration 19 --
136int(11)
137bool(false)
138-- Iteration 20 --
139int(13)
140bool(false)
141-- Iteration 21 --
142int(14)
143bool(false)
144-- Iteration 22 --
145int(16)
146bool(false)
147-- Iteration 23 --
148int(17)
149bool(false)
150-- Iteration 24 --
151int(20)
152bool(false)
153-- Iteration 25 --
154int(22)
155bool(false)
156-- Iteration 26 --
157int(23)
158bool(false)
159-- Iteration 27 --
160int(24)
161bool(false)
162-- Iteration 28 --
163int(25)
164bool(false)
165-- Iteration 29 --
166bool(false)
167bool(false)
168-- Iteration 30 --
169int(27)
170bool(false)
171-- Iteration 31 --
172int(28)
173bool(false)
174-- Iteration 32 --
175int(29)
176bool(false)
177-- Iteration 33 --
178int(31)
179bool(false)
180-- Iteration 34 --
181int(30)
182bool(false)
183-- Iteration 35 --
184int(32)
185bool(false)
186-- Iteration 36 --
187int(33)
188bool(false)
189-- Iteration 37 --
190int(33)
191bool(false)
192-- Iteration 38 --
193int(39)
194int(39)
195-- Iteration 39 --
196int(15)
197int(48)
198-- Iteration 40 --
199int(15)
200int(48)
201-- Iteration 41 --
202int(51)
203int(51)
204-- Iteration 42 --
205int(51)
206int(51)
207-- Iteration 43 --
208bool(false)
209bool(false)
210-- Iteration 44 --
211int(0)
212bool(false)
213*** Done ***
214