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