1--TEST--
2Test mb_substr() function : basic functionality
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip');
6function_exists('mb_substr') or die("skip mb_substr() is not available in this build");
7?>
8--INI--
9internal_encoding=ISO-8859-1
10--FILE--
11<?php
12/*
13 * Test Basic Functionality of mb_substr with ASCII characters and multibyte strings.
14 */
15
16echo "*** Testing mb_substr() : basic functionality ***\n";
17
18$string_ascii = 'ABCDEF';
19//Japanese string in UTF-8
20$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
21
22echo "\n-- ASCII string 1 --\n";
23var_dump(mb_substr($string_ascii, 3));
24
25echo "\n-- ASCII string 2 --\n";
26var_dump(mb_substr($string_ascii, 3, 5, 'ISO-8859-1'));
27
28echo "\n-- Multibyte string 1 --\n";
29$result_1 = mb_substr($string_mb, 2, 7);
30var_dump(base64_encode($result_1));
31
32echo "\n-- Multibyte string 2 --\n";
33$result_2 = mb_substr($string_mb, 2, 7, 'utf-8');
34var_dump(base64_encode($result_2));
35
36echo "Done";
37?>
38--EXPECT--
39*** Testing mb_substr() : basic functionality ***
40
41-- ASCII string 1 --
42string(3) "DEF"
43
44-- ASCII string 2 --
45string(3) "DEF"
46
47-- Multibyte string 1 --
48string(12) "peacrOiqng=="
49
50-- Multibyte string 2 --
51string(28) "6Kqe44OG44Kt44K544OI44Gn44GZ"
52Done
53