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/* Prototype  : int mb_strripos(string haystack, string needle [, int offset [, string encoding]])
11 * Description: Finds position of last 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_strripos with ASCII and multibyte characters
18 */
19
20echo "*** Testing mb_strripos() : 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_strripos($haystack, $needle));
60      var_dump(mb_strripos($haystack, $needle, 14));
61   }
62}
63
64echo "\n -- Greek Strings --\n";
65foreach ($greek_needles as $needle) {
66   foreach ($greek_haystacks as $haystack) {
67      var_dump(mb_strripos($haystack, $needle));
68      var_dump(mb_strripos($haystack, $needle, 12));
69   }
70}
71
72echo "Done";
73?>
74--EXPECT--
75*** Testing mb_strripos() : basic functionality***
76
77 -- ASCII Strings --
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)
96int(13)
97bool(false)
98int(13)
99bool(false)
100int(13)
101bool(false)
102
103 -- Greek Strings --
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)
122int(11)
123bool(false)
124int(11)
125bool(false)
126int(11)
127bool(false)
128Done
129