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