Annotation of embedaddon/php/ext/standard/tests/strings/strrpos_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strrpos() function : usage variations - double quoted strings for 'haystack' & 'needle' arguments
3: --FILE--
4: <?php
5: /* Prototype : int strrpos ( string $haystack, string $needle [, int $offset] );
6: * Description: Find position of last occurrence of 'needle' in 'haystack'.
7: * Source code: ext/standard/string.c
8: */
9:
10: /* Test strrpos() function by passing double quoted strings for 'haystack' & 'needle' arguments */
11:
12: echo "*** Testing strrpos() function: with double quoted strings ***\n";
13: $haystack = "Hello,\t\n\0\n $&!#%()*<=>?@hello123456he \x234 \101 ";
14: $needle = array(
15: //regular strings
16: "l",
17: "L",
18: "HELLO",
19: "hEllo",
20:
21: //escape characters
22: "\t",
23: "\T", //invalid input
24: " ",
25: "\n",
26: "\N", //invalid input
27: "
28: ", //new line
29:
30: //nulls
31: "\0",
32: NULL,
33: null,
34:
35: //boolean false
36: FALSE,
37: false,
38:
39: //empty string
40: "",
41:
42: //special chars
43: " ",
44: "$",
45: " $",
46: "&",
47: "!#",
48: "()",
49: "<=>",
50: ">",
51: "=>",
52: "?",
53: "@",
54: "@hEllo",
55:
56: "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: for($index=0; $index<count($needle); $index++) {
68: echo "-- Iteration $count --\n";
69: var_dump( strrpos($haystack, $needle[$index]) );
70: var_dump( strrpos($haystack, $needle[$index], $index) );
71: $count++;
72: }
73: echo "*** Done ***";
74: ?>
75: --EXPECTF--
76: *** Testing strrpos() function: with double quoted strings ***
77: -- Iteration 1 --
78: int(28)
79: int(28)
80: -- Iteration 2 --
81: bool(false)
82: bool(false)
83: -- Iteration 3 --
84: bool(false)
85: bool(false)
86: -- Iteration 4 --
87: bool(false)
88: bool(false)
89: -- Iteration 5 --
90: int(6)
91: int(6)
92: -- Iteration 6 --
93: bool(false)
94: bool(false)
95: -- Iteration 7 --
96: bool(false)
97: bool(false)
98: -- Iteration 8 --
99: int(9)
100: int(9)
101: -- Iteration 9 --
102: bool(false)
103: bool(false)
104: -- Iteration 10 --
105: int(9)
106: int(9)
107: -- Iteration 11 --
108: int(8)
109: bool(false)
110: -- Iteration 12 --
111: int(8)
112: bool(false)
113: -- Iteration 13 --
114: int(8)
115: bool(false)
116: -- Iteration 14 --
117: int(8)
118: bool(false)
119: -- Iteration 15 --
120: int(8)
121: bool(false)
122: -- Iteration 16 --
123: bool(false)
124: bool(false)
125: -- Iteration 17 --
126: int(43)
127: int(43)
128: -- Iteration 18 --
129: int(12)
130: bool(false)
131: -- Iteration 19 --
132: int(11)
133: bool(false)
134: -- Iteration 20 --
135: int(13)
136: bool(false)
137: -- Iteration 21 --
138: int(14)
139: bool(false)
140: -- Iteration 22 --
141: int(17)
142: bool(false)
143: -- Iteration 23 --
144: int(20)
145: bool(false)
146: -- Iteration 24 --
147: int(22)
148: bool(false)
149: -- Iteration 25 --
150: int(21)
151: bool(false)
152: -- Iteration 26 --
153: int(23)
154: bool(false)
155: -- Iteration 27 --
156: int(24)
157: bool(false)
158: -- Iteration 28 --
159: bool(false)
160: bool(false)
161: -- Iteration 29 --
162: int(30)
163: int(30)
164: -- Iteration 30 --
165: int(39)
166: int(39)
167: -- Iteration 31 --
168: int(39)
169: int(39)
170: -- Iteration 32 --
171: int(42)
172: int(42)
173: -- Iteration 33 --
174: int(42)
175: int(42)
176: -- Iteration 34 --
177: bool(false)
178: bool(false)
179: -- Iteration 35 --
180: int(0)
181: bool(false)
182: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>