1--TEST--
2Test mb_strrpos() function : usage variations - pass encoding as third argument (deprecated behaviour)
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip');
6function_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
19echo "*** Testing mb_strrpos() : usage variations ***\n";
20
21$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
22$needle_mb = base64_decode('44CC');
23
24$stringh = <<<END
25utf-8
26END;
27
28$inputs = array('Double Quoted String' => "utf-8",
29                'Single Quoted String' => 'utf-8',
30                'Heredoc' => $stringh);
31foreach ($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
39echo "Done";
40?>
41--EXPECTF--
42*** Testing mb_strrpos() : usage variations ***
43
44-- Double Quoted String --
45-- With fourth encoding argument --
46int(20)
47-- Without fourth encoding argument --
48int(20)
49
50-- Single Quoted String --
51-- With fourth encoding argument --
52int(20)
53-- Without fourth encoding argument --
54int(20)
55
56-- Heredoc --
57-- With fourth encoding argument --
58int(20)
59-- Without fourth encoding argument --
60int(20)
61Done
62