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/* Prototype  : int mb_stripos(string haystack, string needle [, int offset [, string encoding]])
11 * Description: Finds position of first occurrence of a string within another, case insensitive
12 * Source code: ext/mbstring/mbstring.c
13 * Alias to functions:
14 */
15
16/*
17 * Test basic functionality of mb_stripos with ASCII and multibyte characters
18 */
19
20echo "*** Testing mb_stripos() : basic functionality***\n";
21
22mb_internal_encoding('UTF-8');
23
24//ascii strings
25$ascii_haystacks = array(
26   'abc defabc   def',
27   'ABC DEFABC   DEF',
28   'Abc dEFaBC   Def',
29);
30
31$ascii_needles = array(
32   // 4 good ones
33   'DE',
34   'de',
35   'De',
36   'dE',
37);
38
39//greek strings in UTF-8
40$greek_lower = base64_decode('zrrOu868zr3Ovs6/z4DPgSDOus67zrzOvc6+zr/PgA==');
41$greek_upper = base64_decode('zprOm86czp3Ons6fzqDOoSDOms6bzpzOnc6ezp/OoA==');
42$greek_mixed = base64_decode('zrrOu868zr3Ovs6fzqDOoSDOus67zpzOnc6+zr/OoA==');
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_needles = array(
51   // 4 good ones
52   $greek_nlower, $greek_nupper, $greek_nmixed1, $greek_nmixed2,
53);
54
55// try the basic options
56echo "\n -- ASCII Strings --\n";
57foreach ($ascii_needles as $needle) {
58   foreach ($ascii_haystacks as $haystack) {
59      var_dump(mb_stripos($haystack, $needle));
60      var_dump(mb_stripos($haystack, $needle, 6));
61   }
62}
63
64echo "\n -- Greek Strings --\n";
65foreach ($greek_needles as $needle) {
66   foreach ($greek_haystacks as $haystack) {
67      var_dump(mb_stripos($haystack, $needle));
68      var_dump(mb_stripos($haystack, $needle, 4));
69   }
70}
71
72echo "Done";
73?>
74--EXPECT--
75*** Testing mb_stripos() : basic functionality***
76
77 -- ASCII Strings --
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)
96int(4)
97int(13)
98int(4)
99int(13)
100int(4)
101int(13)
102
103 -- Greek Strings --
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)
122int(2)
123int(11)
124int(2)
125int(11)
126int(2)
127int(11)
128Done
129