1--TEST-- 2Test mb_strrchr() function : basic functionality 3--EXTENSIONS-- 4mbstring 5--FILE-- 6<?php 7echo "*** Testing mb_strrchr() : basic functionality ***\n"; 8 9mb_internal_encoding('UTF-8'); 10 11$string_ascii = 'abc def'; 12//Japanese string in UTF-8 13$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); 14 15echo "\n-- ASCII string: needle exists --\n"; 16var_dump(bin2hex(mb_strrchr($string_ascii, 'd', false, 'ISO-8859-1'))); 17var_dump(bin2hex(mb_strrchr($string_ascii, 'd'))); 18var_dump(bin2hex(mb_strrchr($string_ascii, 'd', true))); 19 20echo "\n-- ASCII string: needle doesn't exist --\n"; 21var_dump(mb_strrchr($string_ascii, '123')); 22 23echo "\n-- Multibyte string: needle exists --\n"; 24$needle1 = base64_decode('5pel5pys6Kqe'); 25var_dump(bin2hex(mb_strrchr($string_mb, $needle1))); 26var_dump(bin2hex(mb_strrchr($string_mb, $needle1, false, 'utf-8'))); 27var_dump(bin2hex(mb_strrchr($string_mb, $needle1, true))); 28 29echo "\n-- Multibyte string: needle doesn't exist --\n"; 30$needle2 = base64_decode('44GT44KT44Gr44Gh44Gv44CB5LiW55WM'); 31var_dump(mb_strrchr($string_mb, $needle2)); 32 33echo "\n-- Regression tests --\n"; 34// Regression test from when mb_strrchr was being reimplemented 35var_dump(mb_strrchr("\x00t\x00", "", false, "UTF32")); 36 37?> 38--EXPECT-- 39*** Testing mb_strrchr() : basic functionality *** 40 41-- ASCII string: needle exists -- 42string(6) "646566" 43string(6) "646566" 44string(8) "61626320" 45 46-- ASCII string: needle doesn't exist -- 47bool(false) 48 49-- Multibyte string: needle exists -- 50string(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082" 51string(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082" 52string(0) "" 53 54-- Multibyte string: needle doesn't exist -- 55bool(false) 56 57-- Regression tests -- 58string(0) "" 59