mb_strrichr_basic.phpt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. Test mb_strrichr() function : basic functionality
  3. --EXTENSIONS--
  4. mbstring
  5. --FILE--
  6. <?php
  7. echo "*** Testing mb_strrichr() : basic functionality ***\n";
  8. mb_internal_encoding('UTF-8');
  9. $string_ascii = 'abcdef';
  10. $needle_ascii_upper = "BCD";
  11. $needle_ascii_mixed = "bCd";
  12. $needle_ascii_lower = "bcd";
  13. //Greek string in lower case UTF-8
  14. $string_mb = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J');
  15. $needle_mb_upper = base64_decode('zpzOnc6ezp8=');
  16. $needle_mb_lower = base64_decode('zrzOvc6+zr8=');
  17. $needle_mb_mixed = base64_decode('zpzOnc6+zr8=');
  18. echo "\n-- ASCII string: needle exists --\n";
  19. var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_upper, false, 'ISO-8859-1')));
  20. var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_lower)));
  21. var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_mixed, true)));
  22. echo "\n-- ASCII string: needle doesn't exist --\n";
  23. var_dump(mb_strrichr($string_ascii, '123'));
  24. echo "\n-- Multibyte string: needle exists --\n";
  25. var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_upper)));
  26. var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_lower, false, 'utf-8')));
  27. var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_mixed, true)));
  28. echo "\n-- Multibyte string: needle doesn't exist --\n";
  29. $needle2 = base64_decode('zrzOvs6/');
  30. var_dump(mb_strrichr($string_mb, $needle2));
  31. ?>
  32. --EXPECT--
  33. *** Testing mb_strrichr() : basic functionality ***
  34. -- ASCII string: needle exists --
  35. string(10) "6263646566"
  36. string(10) "6263646566"
  37. string(2) "61"
  38. -- ASCII string: needle doesn't exist --
  39. bool(false)
  40. -- Multibyte string: needle exists --
  41. string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89"
  42. string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89"
  43. string(44) "ceb1ceb2ceb3ceb4ceb5ceb6ceb7ceb8ceb9cebacebb"
  44. -- Multibyte string: needle doesn't exist --
  45. bool(false)