mb_strripos_basic2.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. --TEST--
  2. Test mb_strripos() function : basic functionality
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('mbstring') or die('skip');
  6. function_exists('mb_strripos') or die("skip mb_strripos() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : int mb_strripos(string haystack, string needle [, int offset [, string encoding]])
  11. * Description: Finds position of last occurrence of a string within another, case insensitive
  12. * Source code: ext/mbstring/mbstring.c
  13. * Alias to functions:
  14. */
  15. /*
  16. * Test basic functionality of mb_strripos with ASCII and multibyte characters
  17. */
  18. echo "*** Testing mb_strripos() : basic functionality***\n";
  19. mb_internal_encoding('UTF-8');
  20. //ascii strings
  21. $ascii_haystacks = array(
  22. b'abc defabc def',
  23. b'ABC DEFABC DEF',
  24. b'Abc dEFaBC Def',
  25. );
  26. $ascii_needles = array(
  27. // 4 good ones
  28. b'DE',
  29. b'de',
  30. b'De',
  31. b'dE',
  32. );
  33. //greek strings in UTF-8
  34. $greek_lower = base64_decode('zrrOu868zr3Ovs6/z4DPgSDOus67zrzOvc6+zr/PgA==');
  35. $greek_upper = base64_decode('zprOm86czp3Ons6fzqDOoSDOms6bzpzOnc6ezp/OoA==');
  36. $greek_mixed = base64_decode('zrrOu868zr3Ovs6fzqDOoSDOus67zpzOnc6+zr/OoA==');
  37. $greek_haystacks = array($greek_lower, $greek_upper, $greek_mixed);
  38. $greek_nlower = base64_decode('zrzOvc6+zr8=');
  39. $greek_nupper = base64_decode('zpzOnc6ezp8=');
  40. $greek_nmixed1 = base64_decode('zpzOnc6+zr8=');
  41. $greek_nmixed2 = base64_decode('zrzOvc6+zp8=');
  42. $greek_needles = array(
  43. // 4 good ones
  44. $greek_nlower, $greek_nupper, $greek_nmixed1, $greek_nmixed2,
  45. );
  46. // try the basic options
  47. echo "\n -- ASCII Strings --\n";
  48. foreach ($ascii_needles as $needle) {
  49. foreach ($ascii_haystacks as $haystack) {
  50. var_dump(mb_strripos($haystack, $needle));
  51. var_dump(mb_strripos($haystack, $needle, 14));
  52. }
  53. }
  54. echo "\n -- Greek Strings --\n";
  55. foreach ($greek_needles as $needle) {
  56. foreach ($greek_haystacks as $haystack) {
  57. var_dump(mb_strripos($haystack, $needle));
  58. var_dump(mb_strripos($haystack, $needle, 12));
  59. }
  60. }
  61. echo "Done";
  62. ?>
  63. --EXPECTF--
  64. *** Testing mb_strripos() : basic functionality***
  65. -- ASCII Strings --
  66. int(13)
  67. bool(false)
  68. int(13)
  69. bool(false)
  70. int(13)
  71. bool(false)
  72. int(13)
  73. bool(false)
  74. int(13)
  75. bool(false)
  76. int(13)
  77. bool(false)
  78. int(13)
  79. bool(false)
  80. int(13)
  81. bool(false)
  82. int(13)
  83. bool(false)
  84. int(13)
  85. bool(false)
  86. int(13)
  87. bool(false)
  88. int(13)
  89. bool(false)
  90. -- Greek Strings --
  91. int(11)
  92. bool(false)
  93. int(11)
  94. bool(false)
  95. int(11)
  96. bool(false)
  97. int(11)
  98. bool(false)
  99. int(11)
  100. bool(false)
  101. int(11)
  102. bool(false)
  103. int(11)
  104. bool(false)
  105. int(11)
  106. bool(false)
  107. int(11)
  108. bool(false)
  109. int(11)
  110. bool(false)
  111. int(11)
  112. bool(false)
  113. int(11)
  114. bool(false)
  115. Done