mb_strstr_variation6.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --TEST--
  2. Test mb_strstr() function : variation - case sensitivity
  3. --EXTENSIONS--
  4. mbstring
  5. --FILE--
  6. <?php
  7. echo "*** Testing mb_strstr() : variation ***\n";
  8. mb_internal_encoding('UTF-8');
  9. //ascii
  10. $string_ascii = 'abcdef';
  11. $needle_ascii_upper = "BCD";
  12. $needle_ascii_mixed = "bCd";
  13. $needle_ascii_lower = "bcd";
  14. //Greek string in lower case UTF-8
  15. $string_mb = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J');
  16. $needle_mb_upper = base64_decode('zpzOnc6ezp8=');
  17. $needle_mb_lower = base64_decode('zrzOvc6+zr8=');
  18. $needle_mb_mixed = base64_decode('zpzOnc6+zr8=');
  19. echo "-- Ascii data --\n";
  20. // needle should be found
  21. var_dump(bin2hex(mb_strstr($string_ascii, $needle_ascii_lower)));
  22. // no needle should be found
  23. var_dump(mb_strstr($string_ascii, $needle_ascii_upper));
  24. var_dump(mb_strstr($string_ascii, $needle_ascii_mixed));
  25. echo "-- mb data in utf-8 --\n";
  26. // needle should be found
  27. $res = mb_strstr($string_mb, $needle_mb_lower, false);
  28. if ($res !== false) {
  29. var_dump(bin2hex($res));
  30. }
  31. else {
  32. echo "nothing found!\n";
  33. }
  34. // no needle should be found
  35. var_dump(mb_strstr($string_mb, $needle_mb_upper));
  36. var_dump(mb_strstr($string_mb, $needle_mb_mixed));
  37. ?>
  38. --EXPECT--
  39. *** Testing mb_strstr() : variation ***
  40. -- Ascii data --
  41. string(10) "6263646566"
  42. bool(false)
  43. bool(false)
  44. -- mb data in utf-8 --
  45. string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89"
  46. bool(false)
  47. bool(false)