1--TEST--
2Test strripos() function : usage variations - double 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 double quoted strings for 'haystack' & 'needle' arguments */
11
12echo "*** Testing strripos() function: with double 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",  //invalid input
24		  "     ",
25		  "\n",
26		  "\N",  //invalid input
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 of \101
61		  "456HEE",  //numerics + chars
62		  $haystack  //haystack as needle
63);
64
65/* loop through to get the position of the needle in haystack string */
66$count = 1;
67foreach ($needles as $needle) {
68  echo "-- Iteration $count --\n";
69  var_dump( strripos($haystack, $needle) );
70  var_dump( strripos($haystack, $needle, 1) );
71  var_dump( strripos($haystack, $needle, 20) );
72  var_dump( strripos($haystack, $needle, -1) );
73  $count++;
74}
75?>
76===DONE===
77--EXPECTF--
78*** Testing strripos() function: with double quoted strings ***
79-- Iteration 1 --
80int(28)
81int(28)
82int(28)
83int(28)
84-- Iteration 2 --
85int(28)
86int(28)
87int(28)
88int(28)
89-- Iteration 3 --
90int(25)
91int(25)
92int(25)
93int(25)
94-- Iteration 4 --
95int(25)
96int(25)
97int(25)
98int(25)
99-- Iteration 5 --
100int(6)
101int(6)
102bool(false)
103int(6)
104-- Iteration 6 --
105bool(false)
106bool(false)
107bool(false)
108bool(false)
109-- Iteration 7 --
110bool(false)
111bool(false)
112bool(false)
113bool(false)
114-- Iteration 8 --
115int(9)
116int(9)
117bool(false)
118int(9)
119-- Iteration 9 --
120bool(false)
121bool(false)
122bool(false)
123bool(false)
124-- Iteration 10 --
125int(9)
126int(9)
127bool(false)
128int(9)
129-- Iteration 11 --
130int(8)
131int(8)
132bool(false)
133int(8)
134-- Iteration 12 --
135int(8)
136int(8)
137bool(false)
138int(8)
139-- Iteration 13 --
140int(8)
141int(8)
142bool(false)
143int(8)
144-- Iteration 14 --
145int(8)
146int(8)
147bool(false)
148int(8)
149-- Iteration 15 --
150int(8)
151int(8)
152bool(false)
153int(8)
154-- Iteration 16 --
155bool(false)
156bool(false)
157bool(false)
158bool(false)
159-- Iteration 17 --
160int(43)
161int(43)
162int(43)
163int(43)
164-- Iteration 18 --
165int(12)
166int(12)
167bool(false)
168int(12)
169-- Iteration 19 --
170int(11)
171int(11)
172bool(false)
173int(11)
174-- Iteration 20 --
175int(13)
176int(13)
177bool(false)
178int(13)
179-- Iteration 21 --
180int(14)
181int(14)
182bool(false)
183int(14)
184-- Iteration 22 --
185int(17)
186int(17)
187bool(false)
188int(17)
189-- Iteration 23 --
190int(20)
191int(20)
192int(20)
193int(20)
194-- Iteration 24 --
195int(22)
196int(22)
197int(22)
198int(22)
199-- Iteration 25 --
200int(21)
201int(21)
202int(21)
203int(21)
204-- Iteration 26 --
205int(23)
206int(23)
207int(23)
208int(23)
209-- Iteration 27 --
210int(24)
211int(24)
212int(24)
213int(24)
214-- Iteration 28 --
215int(24)
216int(24)
217int(24)
218int(24)
219-- Iteration 29 --
220int(30)
221int(30)
222int(30)
223int(30)
224-- Iteration 30 --
225int(39)
226int(39)
227int(39)
228int(39)
229-- Iteration 31 --
230int(39)
231int(39)
232int(39)
233int(39)
234-- Iteration 32 --
235int(42)
236int(42)
237int(42)
238int(42)
239-- Iteration 33 --
240int(42)
241int(42)
242int(42)
243int(42)
244-- Iteration 34 --
245bool(false)
246bool(false)
247bool(false)
248bool(false)
249-- Iteration 35 --
250int(0)
251bool(false)
252bool(false)
253int(0)
254===DONE===
255