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