mb_strripos_basic2.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. --TEST--
  2. Test mb_strripos() function : basic functionality
  3. --EXTENSIONS--
  4. mbstring
  5. --FILE--
  6. <?php
  7. /*
  8. * Test basic functionality of mb_strripos with ASCII and multibyte characters
  9. */
  10. echo "*** Testing mb_strripos() : basic functionality***\n";
  11. mb_internal_encoding('UTF-8');
  12. //ascii strings
  13. $ascii_haystacks = array(
  14. 'abc defabc def',
  15. 'ABC DEFABC DEF',
  16. 'Abc dEFaBC Def',
  17. );
  18. $ascii_needles = array(
  19. // 4 good ones
  20. 'DE',
  21. 'de',
  22. 'De',
  23. 'dE',
  24. );
  25. //greek strings in UTF-8
  26. $greek_lower = base64_decode('zrrOu868zr3Ovs6/z4DPgSDOus67zrzOvc6+zr/PgA==');
  27. $greek_upper = base64_decode('zprOm86czp3Ons6fzqDOoSDOms6bzpzOnc6ezp/OoA==');
  28. $greek_mixed = base64_decode('zrrOu868zr3Ovs6fzqDOoSDOus67zpzOnc6+zr/OoA==');
  29. $greek_haystacks = array($greek_lower, $greek_upper, $greek_mixed);
  30. $greek_nlower = base64_decode('zrzOvc6+zr8=');
  31. $greek_nupper = base64_decode('zpzOnc6ezp8=');
  32. $greek_nmixed1 = base64_decode('zpzOnc6+zr8=');
  33. $greek_nmixed2 = base64_decode('zrzOvc6+zp8=');
  34. $greek_needles = array(
  35. // 4 good ones
  36. $greek_nlower, $greek_nupper, $greek_nmixed1, $greek_nmixed2,
  37. );
  38. // try the basic options
  39. echo "\n -- ASCII Strings --\n";
  40. foreach ($ascii_needles as $needle) {
  41. foreach ($ascii_haystacks as $haystack) {
  42. var_dump(mb_strripos($haystack, $needle));
  43. var_dump(mb_strripos($haystack, $needle, 14));
  44. }
  45. }
  46. echo "\n -- Greek Strings --\n";
  47. foreach ($greek_needles as $needle) {
  48. foreach ($greek_haystacks as $haystack) {
  49. var_dump(mb_strripos($haystack, $needle));
  50. var_dump(mb_strripos($haystack, $needle, 12));
  51. }
  52. }
  53. echo "Done";
  54. ?>
  55. --EXPECT--
  56. *** Testing mb_strripos() : basic functionality***
  57. -- ASCII Strings --
  58. int(13)
  59. bool(false)
  60. int(13)
  61. bool(false)
  62. int(13)
  63. bool(false)
  64. int(13)
  65. bool(false)
  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. -- Greek Strings --
  83. int(11)
  84. bool(false)
  85. int(11)
  86. bool(false)
  87. int(11)
  88. bool(false)
  89. int(11)
  90. bool(false)
  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. Done