1--TEST--
2Test strrpos() function : usage variations - single quoted strings for 'haystack' & 'needle' arguments
3--FILE--
4<?php
5/* Test strrpos() function by passing single quoted strings to 'haystack' & 'needle' arguments */
6
7echo "*** Testing strrpos() function: with single quoted strings ***\n";
8$haystack = 'Hello,\t\n\0\n  $&!#%()*<=>?@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  '()',
42  '<=>',
43  '>',
44  '=>',
45  '?',
46  '@',
47  '@hEllo',
48
49  '12345', //decimal numeric string
50  '\x23',  //hexadecimal numeric string
51  '#',  //hexadecimal numeric string
52  '\101',  //octal numeric string
53  'A',
54  '456HEE',  //numerics + chars
55  42, //needle as int(ASCII value of '*')
56  $haystack  //haystack as needle
57);
58
59/* loop through to get the position of the needle in haystack string */
60$count = 1;
61for($index=0; $index<count($needle); $index++) {
62  echo "-- Iteration $count --\n";
63  var_dump( strrpos($haystack, $needle[$index]) );
64  var_dump( strrpos($haystack, $needle[$index], $index) );
65  $count++;
66}
67echo "*** Done ***";
68?>
69--EXPECT--
70*** Testing strrpos() function: with single quoted strings ***
71-- Iteration 1 --
72int(32)
73int(32)
74-- Iteration 2 --
75bool(false)
76bool(false)
77-- Iteration 3 --
78bool(false)
79bool(false)
80-- Iteration 4 --
81bool(false)
82bool(false)
83-- Iteration 5 --
84int(6)
85int(6)
86-- Iteration 6 --
87bool(false)
88bool(false)
89-- Iteration 7 --
90bool(false)
91bool(false)
92-- Iteration 8 --
93int(12)
94int(12)
95-- Iteration 9 --
96bool(false)
97bool(false)
98-- Iteration 10 --
99bool(false)
100bool(false)
101-- Iteration 11 --
102int(10)
103int(10)
104-- Iteration 12 --
105int(54)
106int(54)
107-- Iteration 13 --
108int(54)
109int(54)
110-- Iteration 14 --
111int(54)
112int(54)
113-- Iteration 15 --
114int(53)
115int(53)
116-- Iteration 16 --
117int(16)
118int(16)
119-- Iteration 17 --
120int(15)
121bool(false)
122-- Iteration 18 --
123int(17)
124int(17)
125-- Iteration 19 --
126int(18)
127int(18)
128-- Iteration 20 --
129int(21)
130int(21)
131-- Iteration 21 --
132int(24)
133int(24)
134-- Iteration 22 --
135int(26)
136int(26)
137-- Iteration 23 --
138int(25)
139int(25)
140-- Iteration 24 --
141int(27)
142int(27)
143-- Iteration 25 --
144int(28)
145int(28)
146-- Iteration 26 --
147bool(false)
148bool(false)
149-- Iteration 27 --
150int(34)
151int(34)
152-- Iteration 28 --
153int(43)
154int(43)
155-- Iteration 29 --
156int(19)
157bool(false)
158-- Iteration 30 --
159int(49)
160int(49)
161-- Iteration 31 --
162bool(false)
163bool(false)
164-- Iteration 32 --
165bool(false)
166bool(false)
167-- Iteration 33 --
168bool(false)
169bool(false)
170-- Iteration 34 --
171int(0)
172bool(false)
173*** Done ***
174