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