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--EXPECTF--
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 --
136
137Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
138bool(false)
139
140Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
141bool(false)
142
143Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
144bool(false)
145
146Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
147bool(false)
148-- Iteration 13 --
149
150Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
151bool(false)
152
153Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
154bool(false)
155
156Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
157bool(false)
158
159Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
160bool(false)
161-- Iteration 14 --
162
163Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
164bool(false)
165
166Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
167bool(false)
168
169Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
170bool(false)
171
172Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
173bool(false)
174-- Iteration 15 --
175
176Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
177bool(false)
178
179Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
180bool(false)
181
182Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
183bool(false)
184
185Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
186bool(false)
187-- Iteration 16 --
188bool(false)
189bool(false)
190bool(false)
191bool(false)
192-- Iteration 17 --
193int(53)
194int(53)
195int(53)
196int(53)
197-- Iteration 18 --
198int(16)
199int(16)
200bool(false)
201int(16)
202-- Iteration 19 --
203int(15)
204int(15)
205bool(false)
206int(15)
207-- Iteration 20 --
208int(17)
209int(17)
210bool(false)
211int(17)
212-- Iteration 21 --
213int(18)
214int(18)
215bool(false)
216int(18)
217-- Iteration 22 --
218int(21)
219int(21)
220int(21)
221int(21)
222-- Iteration 23 --
223int(24)
224int(24)
225int(24)
226int(24)
227-- Iteration 24 --
228int(26)
229int(26)
230int(26)
231int(26)
232-- Iteration 25 --
233int(25)
234int(25)
235int(25)
236int(25)
237-- Iteration 26 --
238int(27)
239int(27)
240int(27)
241int(27)
242-- Iteration 27 --
243int(28)
244int(28)
245int(28)
246int(28)
247-- Iteration 28 --
248int(28)
249int(28)
250int(28)
251int(28)
252-- Iteration 29 --
253int(34)
254int(34)
255int(34)
256int(34)
257-- Iteration 30 --
258int(43)
259int(43)
260int(43)
261int(43)
262-- Iteration 31 --
263int(19)
264int(19)
265bool(false)
266int(19)
267-- Iteration 32 --
268int(49)
269int(49)
270int(49)
271int(49)
272-- Iteration 33 --
273bool(false)
274bool(false)
275bool(false)
276bool(false)
277-- Iteration 34 --
278bool(false)
279bool(false)
280bool(false)
281bool(false)
282-- Iteration 35 --
283
284Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
285int(23)
286
287Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
288int(23)
289
290Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
291int(23)
292
293Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
294int(23)
295-- Iteration 36 --
296int(0)
297bool(false)
298bool(false)
299int(0)
300===DONE===
301