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