1--TEST--
2Test mb_strripos() function : basic functionality
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip');
6function_exists('mb_strripos') or die("skip mb_strripos() is not available in this build");
7?>
8--FILE--
9<?php
10/*
11 * Test basic functionality of mb_strripos with ASCII and multibyte characters
12 */
13
14echo "*** Testing mb_strripos() : 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_strripos($haystack, $needle));
54      var_dump(mb_strripos($haystack, $needle, 14));
55   }
56}
57
58echo "\n -- Greek Strings --\n";
59foreach ($greek_needles as $needle) {
60   foreach ($greek_haystacks as $haystack) {
61      var_dump(mb_strripos($haystack, $needle));
62      var_dump(mb_strripos($haystack, $needle, 12));
63   }
64}
65
66echo "Done";
67?>
68--EXPECT--
69*** Testing mb_strripos() : basic functionality***
70
71 -- ASCII Strings --
72int(13)
73bool(false)
74int(13)
75bool(false)
76int(13)
77bool(false)
78int(13)
79bool(false)
80int(13)
81bool(false)
82int(13)
83bool(false)
84int(13)
85bool(false)
86int(13)
87bool(false)
88int(13)
89bool(false)
90int(13)
91bool(false)
92int(13)
93bool(false)
94int(13)
95bool(false)
96
97 -- Greek Strings --
98int(11)
99bool(false)
100int(11)
101bool(false)
102int(11)
103bool(false)
104int(11)
105bool(false)
106int(11)
107bool(false)
108int(11)
109bool(false)
110int(11)
111bool(false)
112int(11)
113bool(false)
114int(11)
115bool(false)
116int(11)
117bool(false)
118int(11)
119bool(false)
120int(11)
121bool(false)
122Done
123