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