File: mb_strripos_basic2.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (119 lines) | stat: -rw-r--r-- 2,190 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
--TEST--
Test mb_strripos() function : basic functionality
--EXTENSIONS--
mbstring
--FILE--
<?php
/*
 * Test basic functionality of mb_strripos with ASCII and multibyte characters
 */

echo "*** Testing mb_strripos() : basic functionality***\n";

mb_internal_encoding('UTF-8');

//ascii strings
$ascii_haystacks = array(
   'abc defabc   def',
   'ABC DEFABC   DEF',
   'Abc dEFaBC   Def',
);

$ascii_needles = array(
   // 4 good ones
   'DE',
   'de',
   'De',
   'dE',
);

//greek strings in UTF-8
$greek_lower = base64_decode('zrrOu868zr3Ovs6/z4DPgSDOus67zrzOvc6+zr/PgA==');
$greek_upper = base64_decode('zprOm86czp3Ons6fzqDOoSDOms6bzpzOnc6ezp/OoA==');
$greek_mixed = base64_decode('zrrOu868zr3Ovs6fzqDOoSDOus67zpzOnc6+zr/OoA==');
$greek_haystacks = array($greek_lower, $greek_upper, $greek_mixed);

$greek_nlower = base64_decode('zrzOvc6+zr8=');
$greek_nupper = base64_decode('zpzOnc6ezp8=');
$greek_nmixed1 = base64_decode('zpzOnc6+zr8=');
$greek_nmixed2 = base64_decode('zrzOvc6+zp8=');

$greek_needles = array(
   // 4 good ones
   $greek_nlower, $greek_nupper, $greek_nmixed1, $greek_nmixed2,
);

// try the basic options
echo "\n -- ASCII Strings --\n";
foreach ($ascii_needles as $needle) {
   foreach ($ascii_haystacks as $haystack) {
      var_dump(mb_strripos($haystack, $needle));
      var_dump(mb_strripos($haystack, $needle, 14));
   }
}

echo "\n -- Greek Strings --\n";
foreach ($greek_needles as $needle) {
   foreach ($greek_haystacks as $haystack) {
      var_dump(mb_strripos($haystack, $needle));
      var_dump(mb_strripos($haystack, $needle, 12));
   }
}

echo "Done";
?>
--EXPECT--
*** Testing mb_strripos() : basic functionality***

 -- ASCII Strings --
int(13)
bool(false)
int(13)
bool(false)
int(13)
bool(false)
int(13)
bool(false)
int(13)
bool(false)
int(13)
bool(false)
int(13)
bool(false)
int(13)
bool(false)
int(13)
bool(false)
int(13)
bool(false)
int(13)
bool(false)
int(13)
bool(false)

 -- Greek Strings --
int(11)
bool(false)
int(11)
bool(false)
int(11)
bool(false)
int(11)
bool(false)
int(11)
bool(false)
int(11)
bool(false)
int(11)
bool(false)
int(11)
bool(false)
int(11)
bool(false)
int(11)
bool(false)
int(11)
bool(false)
int(11)
bool(false)
Done