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