mb_stripos_basic2.phpt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. --TEST--
  2. Test mb_stripos() function : basic functionality
  3. --EXTENSIONS--
  4. mbstring
  5. --FILE--
  6. <?php
  7. /*
  8. * Test basic functionality of mb_stripos with ASCII and multibyte characters
  9. */
  10. echo "*** Testing mb_stripos() : 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_stripos($haystack, $needle));
  43. var_dump(mb_stripos($haystack, $needle, 6));
  44. }
  45. }
  46. echo "\n -- Greek Strings --\n";
  47. foreach ($greek_needles as $needle) {
  48. foreach ($greek_haystacks as $haystack) {
  49. var_dump(mb_stripos($haystack, $needle));
  50. var_dump(mb_stripos($haystack, $needle, 4));
  51. }
  52. }
  53. echo "Done";
  54. ?>
  55. --EXPECT--
  56. *** Testing mb_stripos() : basic functionality***
  57. -- ASCII Strings --
  58. int(4)
  59. int(13)
  60. int(4)
  61. int(13)
  62. int(4)
  63. int(13)
  64. int(4)
  65. int(13)
  66. int(4)
  67. int(13)
  68. int(4)
  69. int(13)
  70. int(4)
  71. int(13)
  72. int(4)
  73. int(13)
  74. int(4)
  75. int(13)
  76. int(4)
  77. int(13)
  78. int(4)
  79. int(13)
  80. int(4)
  81. int(13)
  82. -- Greek Strings --
  83. int(2)
  84. int(11)
  85. int(2)
  86. int(11)
  87. int(2)
  88. int(11)
  89. int(2)
  90. int(11)
  91. int(2)
  92. int(11)
  93. int(2)
  94. int(11)
  95. int(2)
  96. int(11)
  97. int(2)
  98. int(11)
  99. int(2)
  100. int(11)
  101. int(2)
  102. int(11)
  103. int(2)
  104. int(11)
  105. int(2)
  106. int(11)
  107. Done