mb_str_functions.rst 1015 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. =========================
  2. Rule ``mb_str_functions``
  3. =========================
  4. Replace non multibyte-safe functions with corresponding mb function.
  5. .. warning:: Using this rule is risky.
  6. Risky when any of the functions are overridden.
  7. Examples
  8. --------
  9. Example #1
  10. ~~~~~~~~~~
  11. .. code-block:: diff
  12. --- Original
  13. +++ New
  14. @@ -1,13 +1,13 @@
  15. <?php
  16. -$a = strlen($a);
  17. -$a = strpos($a, $b);
  18. -$a = strrpos($a, $b);
  19. -$a = substr($a, $b);
  20. -$a = strtolower($a);
  21. -$a = strtoupper($a);
  22. -$a = stripos($a, $b);
  23. -$a = strripos($a, $b);
  24. -$a = strstr($a, $b);
  25. -$a = stristr($a, $b);
  26. -$a = strrchr($a, $b);
  27. -$a = substr_count($a, $b);
  28. +$a = mb_strlen($a);
  29. +$a = mb_strpos($a, $b);
  30. +$a = mb_strrpos($a, $b);
  31. +$a = mb_substr($a, $b);
  32. +$a = mb_strtolower($a);
  33. +$a = mb_strtoupper($a);
  34. +$a = mb_stripos($a, $b);
  35. +$a = mb_strripos($a, $b);
  36. +$a = mb_strstr($a, $b);
  37. +$a = mb_stristr($a, $b);
  38. +$a = mb_strrchr($a, $b);
  39. +$a = mb_substr_count($a, $b);