Annotation of embedaddon/php/ext/standard/tests/strings/strripos_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
12: echo "*** 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;
67: foreach ($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 --
80: int(28)
81: int(28)
82: int(28)
83: int(28)
84: -- Iteration 2 --
85: int(28)
86: int(28)
87: int(28)
88: int(28)
89: -- Iteration 3 --
90: int(25)
91: int(25)
92: int(25)
93: int(25)
94: -- Iteration 4 --
95: int(25)
96: int(25)
97: int(25)
98: int(25)
99: -- Iteration 5 --
100: int(6)
101: int(6)
102: bool(false)
103: int(6)
104: -- Iteration 6 --
105: bool(false)
106: bool(false)
107: bool(false)
108: bool(false)
109: -- Iteration 7 --
110: bool(false)
111: bool(false)
112: bool(false)
113: bool(false)
114: -- Iteration 8 --
115: int(9)
116: int(9)
117: bool(false)
118: int(9)
119: -- Iteration 9 --
120: bool(false)
121: bool(false)
122: bool(false)
123: bool(false)
124: -- Iteration 10 --
125: int(9)
126: int(9)
127: bool(false)
128: int(9)
129: -- Iteration 11 --
130: int(8)
131: int(8)
132: bool(false)
133: int(8)
134: -- Iteration 12 --
135: int(8)
136: int(8)
137: bool(false)
138: int(8)
139: -- Iteration 13 --
140: int(8)
141: int(8)
142: bool(false)
143: int(8)
144: -- Iteration 14 --
145: int(8)
146: int(8)
147: bool(false)
148: int(8)
149: -- Iteration 15 --
150: int(8)
151: int(8)
152: bool(false)
153: int(8)
154: -- Iteration 16 --
155: bool(false)
156: bool(false)
157: bool(false)
158: bool(false)
159: -- Iteration 17 --
160: int(43)
161: int(43)
162: int(43)
163: int(43)
164: -- Iteration 18 --
165: int(12)
166: int(12)
167: bool(false)
168: int(12)
169: -- Iteration 19 --
170: int(11)
171: int(11)
172: bool(false)
173: int(11)
174: -- Iteration 20 --
175: int(13)
176: int(13)
177: bool(false)
178: int(13)
179: -- Iteration 21 --
180: int(14)
181: int(14)
182: bool(false)
183: int(14)
184: -- Iteration 22 --
185: int(17)
186: int(17)
187: bool(false)
188: int(17)
189: -- Iteration 23 --
190: int(20)
191: int(20)
192: int(20)
193: int(20)
194: -- Iteration 24 --
195: int(22)
196: int(22)
197: int(22)
198: int(22)
199: -- Iteration 25 --
200: int(21)
201: int(21)
202: int(21)
203: int(21)
204: -- Iteration 26 --
205: int(23)
206: int(23)
207: int(23)
208: int(23)
209: -- Iteration 27 --
210: int(24)
211: int(24)
212: int(24)
213: int(24)
214: -- Iteration 28 --
215: int(24)
216: int(24)
217: int(24)
218: int(24)
219: -- Iteration 29 --
220: int(30)
221: int(30)
222: int(30)
223: int(30)
224: -- Iteration 30 --
225: int(39)
226: int(39)
227: int(39)
228: int(39)
229: -- Iteration 31 --
230: int(39)
231: int(39)
232: int(39)
233: int(39)
234: -- Iteration 32 --
235: int(42)
236: int(42)
237: int(42)
238: int(42)
239: -- Iteration 33 --
240: int(42)
241: int(42)
242: int(42)
243: int(42)
244: -- Iteration 34 --
245: bool(false)
246: bool(false)
247: bool(false)
248: bool(false)
249: -- Iteration 35 --
250: int(0)
251: bool(false)
252: bool(false)
253: int(0)
254: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>