Annotation of embedaddon/php/ext/mbstring/tests/mb_strstr_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mb_strstr() function : variation - multiple needles
3: --SKIPIF--
4: <?php
5: extension_loaded('mbstring') or die('skip');
6: function_exists('mb_strstr') or die("skip mb_strstr() is not available in this build");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : string mb_strstr(string haystack, string needle[, bool part[, string encoding]])
11: * Description: Finds first occurrence of a string within another
12: * Source code: ext/mbstring/mbstring.c
13: * Alias to functions:
14: */
15:
16: echo "*** Testing mb_strstr() : variation ***\n";
17:
18: mb_internal_encoding('UTF-8');
19:
20: //with repeated needles
21: $string_ascii = b'abcdef zbcdyx';
22: $needle_ascii = b"bcd";
23:
24: //Japanese string in UTF-8 with repeated needles
25: $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OIMzTvvJXvvJbml6XmnKzoqp7jg4bjgq3jgrnjg4g=');
26: $needle_mb = base64_decode('6Kqe44OG44Kt');
27:
28: echo "-- Ascii data --\n";
29: var_dump(bin2hex(mb_strstr($string_ascii, $needle_ascii, false)));
30: var_dump(bin2hex(mb_strstr($string_ascii, $needle_ascii, true)));
31:
32: echo "-- mb data in utf-8 --\n";
33: $res = mb_strstr($string_mb, $needle_mb, false);
34: if ($res !== false) {
35: var_dump(bin2hex($res));
36: }
37: else {
38: echo "nothing found!\n";
39: }
40: $res = mb_strstr($string_mb, $needle_mb, true);
41: if ($res !== false) {
42: var_dump(bin2hex($res));
43: }
44: else {
45: echo "nothing found!\n";
46: }
47:
48:
49: ?>
50: ===DONE===
51: --EXPECT--
52: *** Testing mb_strstr() : variation ***
53: -- Ascii data --
54: string(24) "6263646566207a6263647978"
55: string(2) "61"
56: -- mb data in utf-8 --
57: string(88) "e8aa9ee38386e382ade382b9e383883334efbc95efbc96e697a5e69cace8aa9ee38386e382ade382b9e38388"
58: string(12) "e697a5e69cac"
59: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>