菜谱项目

BinaryOnFuncOverload.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Polyfill\Util;
  11. /**
  12. * Binary safe version of string functions overloaded when MB_OVERLOAD_STRING is enabled.
  13. *
  14. * @author Nicolas Grekas <p@tchwork.com>
  15. *
  16. * @internal
  17. */
  18. class BinaryOnFuncOverload
  19. {
  20. public static function strlen($s)
  21. {
  22. return mb_strlen($s, '8bit');
  23. }
  24. public static function strpos($haystack, $needle, $offset = 0)
  25. {
  26. return mb_strpos($haystack, $needle, $offset, '8bit');
  27. }
  28. public static function strrpos($haystack, $needle, $offset = 0)
  29. {
  30. return mb_strrpos($haystack, $needle, $offset, '8bit');
  31. }
  32. public static function substr($string, $start, $length = 2147483647)
  33. {
  34. return mb_substr($string, $start, $length, '8bit');
  35. }
  36. public static function stripos($s, $needle, $offset = 0)
  37. {
  38. return mb_stripos($s, $needle, $offset, '8bit');
  39. }
  40. public static function stristr($s, $needle, $part = false)
  41. {
  42. return mb_stristr($s, $needle, $part, '8bit');
  43. }
  44. public static function strrchr($s, $needle, $part = false)
  45. {
  46. return mb_strrchr($s, $needle, $part, '8bit');
  47. }
  48. public static function strripos($s, $needle, $offset = 0)
  49. {
  50. return mb_strripos($s, $needle, $offset, '8bit');
  51. }
  52. public static function strstr($s, $needle, $part = false)
  53. {
  54. return mb_strstr($s, $needle, $part, '8bit');
  55. }
  56. }