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   //flag a swap between good and bad
30   '!',
31
32   // 4 bad ones
33   'df',
34   'Df',
35   'dF',
36   'DF'
37);
38
39//greek strings in UTF-8
40$greek_lower = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J');
41$greek_upper = base64_decode('zpHOks6TzpTOlc6WzpfOmM6ZzprOm86czp3Ons6fzqDOoc6jzqTOpc6mzqfOqM6p');
42$greek_mixed = base64_decode('zrHOss6TzpTOlc6WzpfOmM65zrrOu868zr3Ovs6fzqDOoc6jzqTOpc+Gz4fPiM+J');
43$greek_haystacks = array($greek_lower, $greek_upper, $greek_mixed);
44
45$greek_nlower = base64_decode('zrzOvc6+zr8=');
46$greek_nupper = base64_decode('zpzOnc6ezp8=');
47$greek_nmixed1 = base64_decode('zpzOnc6+zr8=');
48$greek_nmixed2 = base64_decode('zrzOvc6+zp8=');
49
50$greek_blower = base64_decode('zpzOns6f');
51$greek_bupper = base64_decode('zrzOvs6/');
52$greek_bmixed1 = base64_decode('zpzOvs6/');
53$greek_bmixed2 = base64_decode('zrzOvs6f');
54$greek_needles = array(
55   // 4 good ones
56   $greek_nlower, $greek_nupper, $greek_nmixed1, $greek_nmixed2,
57
58   '!', // used to flag a swap between good and bad
59
60   // 4 bad ones
61   $greek_blower, $greek_bupper, $greek_bmixed1, $greek_bmixed2,
62);
63
64// try the basic options
65echo "\n -- ASCII Strings, needle should be found --\n";
66foreach ($ascii_needles as $needle) {
67   if ($needle == '!') {
68      echo "\n -- ASCII Strings, needle should not be found --\n";
69   }
70   else {
71      foreach ($ascii_haystacks as $haystack) {
72         var_dump(mb_stripos($haystack, $needle));
73      }
74   }
75}
76
77echo "\n -- Greek Strings, needle should be found --\n";
78foreach ($greek_needles as $needle) {
79   if ($needle == '!') {
80      echo "\n -- ASCII Strings, needle should not be found --\n";
81   }
82   else {
83      foreach ($greek_haystacks as $haystack) {
84         var_dump(mb_stripos($haystack, $needle));
85      }
86   }
87}
88
89echo "Done";
90?>
91--EXPECT--
92*** Testing mb_stripos() : basic functionality***
93
94 -- ASCII Strings, needle should be found --
95int(4)
96int(4)
97int(4)
98int(4)
99int(4)
100int(4)
101int(4)
102int(4)
103int(4)
104int(4)
105int(4)
106int(4)
107
108 -- ASCII Strings, needle should not be found --
109bool(false)
110bool(false)
111bool(false)
112bool(false)
113bool(false)
114bool(false)
115bool(false)
116bool(false)
117bool(false)
118bool(false)
119bool(false)
120bool(false)
121
122 -- Greek Strings, needle should be found --
123int(11)
124int(11)
125int(11)
126int(11)
127int(11)
128int(11)
129int(11)
130int(11)
131int(11)
132int(11)
133int(11)
134int(11)
135
136 -- ASCII Strings, needle should not be found --
137bool(false)
138bool(false)
139bool(false)
140bool(false)
141bool(false)
142bool(false)
143bool(false)
144bool(false)
145bool(false)
146bool(false)
147bool(false)
148bool(false)
149Done
150