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