StringNative.class.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Implements PMA_StringByte interface using native PHP functions.
  5. *
  6. * @package PhpMyAdmin-String
  7. * @subpackage Native
  8. */
  9. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. require_once 'libraries/StringByte.int.php';
  13. /**
  14. * Implements PMA_StringByte interface using native PHP functions.
  15. *
  16. * @package PhpMyAdmin-String
  17. * @subpackage Native
  18. */
  19. class PMA_StringNative implements PMA_StringByte
  20. {
  21. /**
  22. * Returns length of string depending on current charset.
  23. *
  24. * @param string $string string to count
  25. *
  26. * @return int string length
  27. */
  28. public function strlen($string)
  29. {
  30. return strlen($string);
  31. }
  32. /**
  33. * Returns substring from string, works depending on current charset.
  34. *
  35. * @param string $string string to count
  36. * @param int $start start of substring
  37. * @param int $length length of substring
  38. *
  39. * @return string the sub string
  40. */
  41. public function substr($string, $start, $length = 2147483647)
  42. {
  43. return substr($string, $start, $length);
  44. }
  45. /**
  46. * Returns postion of $needle in $haystack or false if not found
  47. *
  48. * @param string $haystack the string being checked
  49. * @param string $needle the string to find in haystack
  50. * @param int $offset the search offset
  51. *
  52. * @return integer position of $needle in $haystack or false
  53. */
  54. public function strpos($haystack, $needle, $offset = 0)
  55. {
  56. return strpos($haystack, $needle, $offset);
  57. }
  58. /**
  59. * Make a string lowercase
  60. *
  61. * @param string $string the string being lowercased
  62. *
  63. * @return string the lower case string
  64. */
  65. public function strtolower($string)
  66. {
  67. return strtolower($string);
  68. }
  69. /**
  70. * Get the ordinal value of a string
  71. *
  72. * @param string $string the string for which ord is required
  73. *
  74. * @return string the ord value
  75. */
  76. public function ord($string)
  77. {
  78. return ord($string);
  79. }
  80. };
  81. ?>