1--TEST--
2Test iconv_strrpos() function : basic functionality
3--SKIPIF--
4<?php
5extension_loaded('iconv') or die('skip');
6function_exists('iconv_strrpos') or die("skip iconv_strrpos() is not available in this build");
7?>
8--INI--
9error_reporting=E_ALL & ~E_DEPRECATED
10--FILE--
11<?php
12/* Prototype  : proto int iconv_strrpos(string haystack, string needle [, string charset])
13 * Description: Find position of last occurrence of a string within another
14 * Source code: ext/iconv/iconv.c
15 */
16
17/*
18 * Test basic functionality of iconv_strrpos()
19 */
20
21echo "*** Testing iconv_strrpos() : basic ***\n";
22
23iconv_set_encoding("internal_encoding", "UTF-8");
24
25$string_ascii = b'This is an English string. 0123456789.';
26//Japanese string in UTF-8
27$string_mb = base64_decode(b'5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
28
29echo "\n-- ASCII string 1 --\n";
30var_dump(iconv_strrpos($string_ascii, b'is', 'ISO-8859-1'));
31
32echo "\n-- ASCII string 2 --\n";
33var_dump(iconv_strrpos($string_ascii, b'hello, world'));
34
35echo "\n-- Multibyte string 1 --\n";
36$needle1 = base64_decode(b'44CC');
37var_dump(iconv_strrpos($string_mb, $needle1));
38
39echo "\n-- Multibyte string 2 --\n";
40$needle2 = base64_decode(b'44GT44KT44Gr44Gh44Gv44CB5LiW55WM');
41var_dump(iconv_strrpos($string_mb, $needle2));
42
43echo "Done";
44?>
45--EXPECTF--
46*** Testing iconv_strrpos() : basic ***
47
48-- ASCII string 1 --
49int(15)
50
51-- ASCII string 2 --
52bool(false)
53
54-- Multibyte string 1 --
55int(20)
56
57-- Multibyte string 2 --
58bool(false)
59Done
60
61