Annotation of embedaddon/php/ext/mbstring/tests/mb_strrpos_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mb_strrpos() function : usage variations - pass encoding as third argument (deprecated behaviour)
3: --SKIPIF--
4: <?php
5: extension_loaded('mbstring') or die('skip');
6: function_exists('mb_strrpos') or die("skip mb_strrpos() is not available in this build");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : int mb_strrpos(string $haystack, string $needle [, int $offset [, string $encoding]])
11: * Description: Find position of last occurrence of a string within another
12: * Source code: ext/mbstring/mbstring.c
13: */
14:
15: /*
16: * Testing deprecated behaviour where third argument can be $encoding
17: */
18:
19: echo "*** Testing mb_strrpos() : usage variations ***\n";
20:
21: $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
22: $needle_mb = base64_decode('44CC');
23:
24: $stringh = <<<END
25: utf-8
26: END;
27:
28: $inputs = array('Double Quoted String' => "utf-8",
29: 'Single Quoted String' => 'utf-8',
30: 'Heredoc' => $stringh);
31: foreach ($inputs as $type => $input) {
32: echo "\n-- $type --\n";
33: echo "-- With fourth encoding argument --\n";
34: var_dump(mb_strrpos($string_mb, $needle_mb, $input, 'utf-8'));
35: echo "-- Without fourth encoding argument --\n";
36: var_dump(mb_strrpos($string_mb, $needle_mb, $input));
37: }
38:
39: echo "Done";
40: ?>
41: --EXPECTF--
42: *** Testing mb_strrpos() : usage variations ***
43:
44: -- Double Quoted String --
45: -- With fourth encoding argument --
46: int(20)
47: -- Without fourth encoding argument --
48: int(20)
49:
50: -- Single Quoted String --
51: -- With fourth encoding argument --
52: int(20)
53: -- Without fourth encoding argument --
54: int(20)
55:
56: -- Heredoc --
57: -- With fourth encoding argument --
58: int(20)
59: -- Without fourth encoding argument --
60: int(20)
61: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>