1--TEST--
2Test stripos() function : usage variations - single quoted strings for 'haystack' & 'needle' arguments
3--FILE--
4<?php
5/* Test stripos() function by passing single quoted strings to 'haystack' & 'needle' arguments */
6
7echo "*** Testing stripos() function: with single 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',
19  '     ',
20  '\n',
21  '\N',
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  '@',
57  '@hEllo',
58
59  '12345', //decimal numeric string
60  '\x23',  //hexadecimal numeric string
61  '#',  //hexadecimal numeric string
62  '\101',  //octal numeric string
63  'A',
64  '456HEE',  //numerics + chars
65  42, //needle as int(ASCII value of '*')
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 single quoted strings ***
81-- Iteration 1 --
82int(2)
83int(2)
84-- Iteration 2 --
85int(2)
86int(2)
87-- Iteration 3 --
88int(0)
89int(38)
90-- Iteration 4 --
91int(0)
92int(38)
93-- Iteration 5 --
94int(6)
95int(6)
96-- Iteration 6 --
97int(6)
98int(6)
99-- Iteration 7 --
100bool(false)
101bool(false)
102-- Iteration 8 --
103int(8)
104int(8)
105-- Iteration 9 --
106int(8)
107int(8)
108-- Iteration 10 --
109bool(false)
110bool(false)
111-- Iteration 11 --
112int(10)
113int(10)
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(14)
125int(14)
126-- Iteration 16 --
127int(16)
128int(16)
129-- Iteration 17 --
130int(15)
131bool(false)
132-- Iteration 18 --
133int(17)
134int(17)
135-- Iteration 19 --
136int(18)
137int(18)
138-- Iteration 20 --
139int(20)
140int(20)
141-- Iteration 21 --
142int(21)
143int(21)
144-- Iteration 22 --
145int(24)
146int(24)
147-- Iteration 23 --
148int(26)
149int(26)
150-- Iteration 24 --
151int(27)
152int(27)
153-- Iteration 25 --
154int(28)
155int(28)
156-- Iteration 26 --
157int(29)
158int(29)
159-- Iteration 27 --
160bool(false)
161bool(false)
162-- Iteration 28 --
163bool(false)
164bool(false)
165-- Iteration 29 --
166int(31)
167int(31)
168-- Iteration 30 --
169int(32)
170int(32)
171-- Iteration 31 --
172int(33)
173int(33)
174-- Iteration 32 --
175int(35)
176int(35)
177-- Iteration 33 --
178int(34)
179int(34)
180-- Iteration 34 --
181int(36)
182int(36)
183-- Iteration 35 --
184int(37)
185int(37)
186-- Iteration 36 --
187int(37)
188int(37)
189-- Iteration 37 --
190int(43)
191int(43)
192-- Iteration 38 --
193int(52)
194int(52)
195-- Iteration 39 --
196int(19)
197bool(false)
198-- Iteration 40 --
199int(58)
200int(58)
201-- Iteration 41 --
202bool(false)
203bool(false)
204-- Iteration 42 --
205bool(false)
206bool(false)
207-- Iteration 43 --
208bool(false)
209bool(false)
210-- Iteration 44 --
211int(0)
212bool(false)
213*** Done ***
214