Annotation of embedaddon/php/ext/standard/tests/strings/str_word_count.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: str_word_count()
3: --FILE--
4: <?php
5: error_reporting(E_ALL);
6: $str = "Hello friend, you're
7: looking good today!";
8: $b =& $str;
9: var_dump(str_word_count($str, 1));
10: var_dump(str_word_count($str, 2));
11: var_dump(str_word_count($str));
12: var_dump(str_word_count($str, 3));
13: var_dump(str_word_count($str, 123));
14: var_dump(str_word_count($str, -1));
15: var_dump(str_word_count($str, 999999999));
16: var_dump(str_word_count($str, array()));
17: var_dump(str_word_count($str, $b));
18: var_dump($str);
19:
20: $str2 = "F0o B4r 1s bar foo";
21: var_dump(str_word_count($str2, NULL, "04"));
22: var_dump(str_word_count($str2, NULL, "01"));
23: var_dump(str_word_count($str2, NULL, "014"));
24: var_dump(str_word_count($str2, NULL, array()));
25: var_dump(str_word_count($str2, NULL, new stdClass));
26: var_dump(str_word_count($str2, NULL, ""));
27: var_dump(str_word_count($str2, 1, "04"));
28: var_dump(str_word_count($str2, 1, "01"));
29: var_dump(str_word_count($str2, 1, "014"));
30: var_dump(str_word_count($str2, 1, array()));
31: var_dump(str_word_count($str2, 1, new stdClass));
32: var_dump(str_word_count($str2, 1, ""));
33: var_dump(str_word_count($str2, 2, "04"));
34: var_dump(str_word_count($str2, 2, "01"));
35: var_dump(str_word_count($str2, 2, "014"));
36: var_dump(str_word_count($str2, 2, array()));
37: var_dump(str_word_count($str2, 2, new stdClass));
38: var_dump(str_word_count($str2, 2, ""));
39: var_dump(str_word_count("foo'0 bar-0var", 2, "0"));
40: var_dump(str_word_count("'foo'", 2));
41: var_dump(str_word_count("'foo'", 2, "'"));
42: var_dump(str_word_count("-foo-", 2));
43: var_dump(str_word_count("-foo-", 2, "-"));
44:
45: echo "Done\n";
46: ?>
47: --EXPECTF--
48: array(6) {
49: [0]=>
50: string(5) "Hello"
51: [1]=>
52: string(6) "friend"
53: [2]=>
54: string(6) "you're"
55: [3]=>
56: string(7) "looking"
57: [4]=>
58: string(4) "good"
59: [5]=>
60: string(5) "today"
61: }
62: array(6) {
63: [0]=>
64: string(5) "Hello"
65: [6]=>
66: string(6) "friend"
67: [14]=>
68: string(6) "you're"
69: [27]=>
70: string(7) "looking"
71: [44]=>
72: string(4) "good"
73: [49]=>
74: string(5) "today"
75: }
76: int(6)
77:
78: Warning: str_word_count(): Invalid format value 3 in %s on line %d
79: bool(false)
80:
81: Warning: str_word_count(): Invalid format value 123 in %s on line %d
82: bool(false)
83:
84: Warning: str_word_count(): Invalid format value -1 in %s on line %d
85: bool(false)
86:
87: Warning: str_word_count(): Invalid format value 999999999 in %s on line %d
88: bool(false)
89:
90: Warning: str_word_count() expects parameter 2 to be long, array given in %s on line %d
91: NULL
92:
93: Warning: str_word_count() expects parameter 2 to be long, string given in %s on line %d
94: NULL
95: string(55) "Hello friend, you're
96: looking good today!"
97: int(5)
98: int(6)
99: int(5)
100:
101: Warning: str_word_count() expects parameter 3 to be string, array given in %s on line %d
102: NULL
103:
104: Warning: str_word_count() expects parameter 3 to be string, object given in %s on line %d
105: NULL
106: int(7)
107: array(5) {
108: [0]=>
109: string(3) "F0o"
110: [1]=>
111: string(3) "B4r"
112: [2]=>
113: string(1) "s"
114: [3]=>
115: string(3) "bar"
116: [4]=>
117: string(3) "foo"
118: }
119: array(6) {
120: [0]=>
121: string(3) "F0o"
122: [1]=>
123: string(1) "B"
124: [2]=>
125: string(1) "r"
126: [3]=>
127: string(2) "1s"
128: [4]=>
129: string(3) "bar"
130: [5]=>
131: string(3) "foo"
132: }
133: array(5) {
134: [0]=>
135: string(3) "F0o"
136: [1]=>
137: string(3) "B4r"
138: [2]=>
139: string(2) "1s"
140: [3]=>
141: string(3) "bar"
142: [4]=>
143: string(3) "foo"
144: }
145:
146: Warning: str_word_count() expects parameter 3 to be string, array given in %s on line %d
147: NULL
148:
149: Warning: str_word_count() expects parameter 3 to be string, object given in %s on line %d
150: NULL
151: array(7) {
152: [0]=>
153: string(1) "F"
154: [1]=>
155: string(1) "o"
156: [2]=>
157: string(1) "B"
158: [3]=>
159: string(1) "r"
160: [4]=>
161: string(1) "s"
162: [5]=>
163: string(3) "bar"
164: [6]=>
165: string(3) "foo"
166: }
167: array(5) {
168: [0]=>
169: string(3) "F0o"
170: [4]=>
171: string(3) "B4r"
172: [9]=>
173: string(1) "s"
174: [11]=>
175: string(3) "bar"
176: [15]=>
177: string(3) "foo"
178: }
179: array(6) {
180: [0]=>
181: string(3) "F0o"
182: [4]=>
183: string(1) "B"
184: [6]=>
185: string(1) "r"
186: [8]=>
187: string(2) "1s"
188: [11]=>
189: string(3) "bar"
190: [15]=>
191: string(3) "foo"
192: }
193: array(5) {
194: [0]=>
195: string(3) "F0o"
196: [4]=>
197: string(3) "B4r"
198: [8]=>
199: string(2) "1s"
200: [11]=>
201: string(3) "bar"
202: [15]=>
203: string(3) "foo"
204: }
205:
206: Warning: str_word_count() expects parameter 3 to be string, array given in %s on line %d
207: NULL
208:
209: Warning: str_word_count() expects parameter 3 to be string, object given in %s on line %d
210: NULL
211: array(7) {
212: [0]=>
213: string(1) "F"
214: [2]=>
215: string(1) "o"
216: [4]=>
217: string(1) "B"
218: [6]=>
219: string(1) "r"
220: [9]=>
221: string(1) "s"
222: [11]=>
223: string(3) "bar"
224: [15]=>
225: string(3) "foo"
226: }
227: array(2) {
228: [0]=>
229: string(5) "foo'0"
230: [6]=>
231: string(8) "bar-0var"
232: }
233: array(1) {
234: [1]=>
235: string(4) "foo'"
236: }
237: array(1) {
238: [0]=>
239: string(5) "'foo'"
240: }
241: array(1) {
242: [1]=>
243: string(3) "foo"
244: }
245: array(1) {
246: [0]=>
247: string(5) "-foo-"
248: }
249: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>