mb_strrchr_basic.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. Test mb_strrchr() function : basic functionality
  3. --EXTENSIONS--
  4. mbstring
  5. --FILE--
  6. <?php
  7. echo "*** Testing mb_strrchr() : basic functionality ***\n";
  8. mb_internal_encoding('UTF-8');
  9. $string_ascii = 'abc def';
  10. //Japanese string in UTF-8
  11. $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
  12. echo "\n-- ASCII string: needle exists --\n";
  13. var_dump(bin2hex(mb_strrchr($string_ascii, 'd', false, 'ISO-8859-1')));
  14. var_dump(bin2hex(mb_strrchr($string_ascii, 'd')));
  15. var_dump(bin2hex(mb_strrchr($string_ascii, 'd', true)));
  16. echo "\n-- ASCII string: needle doesn't exist --\n";
  17. var_dump(mb_strrchr($string_ascii, '123'));
  18. echo "\n-- Multibyte string: needle exists --\n";
  19. $needle1 = base64_decode('5pel5pys6Kqe');
  20. var_dump(bin2hex(mb_strrchr($string_mb, $needle1)));
  21. var_dump(bin2hex(mb_strrchr($string_mb, $needle1, false, 'utf-8')));
  22. var_dump(bin2hex(mb_strrchr($string_mb, $needle1, true)));
  23. echo "\n-- Multibyte string: needle doesn't exist --\n";
  24. $needle2 = base64_decode('44GT44KT44Gr44Gh44Gv44CB5LiW55WM');
  25. var_dump(mb_strrchr($string_mb, $needle2));
  26. ?>
  27. --EXPECT--
  28. *** Testing mb_strrchr() : basic functionality ***
  29. -- ASCII string: needle exists --
  30. string(6) "646566"
  31. string(6) "646566"
  32. string(8) "61626320"
  33. -- ASCII string: needle doesn't exist --
  34. bool(false)
  35. -- Multibyte string: needle exists --
  36. string(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082"
  37. string(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082"
  38. string(0) ""
  39. -- Multibyte string: needle doesn't exist --
  40. bool(false)