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