summaryrefslogtreecommitdiff
path: root/ext/mbstring/tests/mb_stripos_basic.phpt
blob: ee62df7dcc98bc6f40523b7da3be40e72f07a3d7 (plain)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
--TEST--
Test mb_stripos() function : basic functionality
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip');
function_exists('mb_stripos') or die("skip mb_stripos() is not available in this build");
?>
--FILE--
<?php
/* Prototype  : int mb_stripos(string $haystack, string $needle [, int $offset [, string $encoding]])
 * Description: Find position of first occurrence of a string within another 
 * Source code: ext/mbstring/mbstring.c
 */

/*
 * Test basic functionality of mb_stripos with ASCII and multibyte characters
 */

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

mb_internal_encoding('UTF-8');

$string_ascii = 'abc def ABC DEF';
//Japanese string in UTF-8
$string_mb = '日本語テキストです。0123456789。';

echo "\n-- ISO-8859-1 string 1 --\n";
var_dump(mb_stripos($string_ascii, 'd', 0, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 2 --\n";
var_dump(mb_stripos($string_ascii, 'D', 0, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 3 --\n";
var_dump(mb_stripos($string_ascii, 'd', 1, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 4 --\n";
var_dump(mb_stripos($string_ascii, 'D', 1, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 5 --\n";
var_dump(mb_stripos($string_ascii, 'c', 4, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 6 --\n";
var_dump(mb_stripos($string_ascii, 'c D', 0, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 7 --\n";
var_dump(mb_stripos($string_ascii, 'C d', 0, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 8 --\n";
var_dump(mb_stripos($string_ascii, 'deF', 0, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 9 --\n";
var_dump(mb_stripos($string_ascii, '123', 0, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 10 --\n";
var_dump(mb_stripos($string_ascii, 'c D', 1, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 11 --\n";
var_dump(mb_stripos($string_ascii, 'C d', 1, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 12 --\n";
var_dump(mb_stripos($string_ascii, 'deF', 1, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 13 --\n";
var_dump(mb_stripos($string_ascii, '123', 1, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 14 --\n";
var_dump(mb_stripos($string_ascii, 'c D', 4, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 15 --\n";
var_dump(mb_stripos($string_ascii, 'C d', 4, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 16 --\n";
var_dump(mb_stripos($string_ascii, 'deF', 4, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 17 --\n";
var_dump(mb_stripos($string_ascii, 'deF', 5, 'ISO-8859-1'));

echo "\n-- ISO-8859-1 string 18 --\n";
var_dump(mb_stripos($string_ascii, '123', 4, 'ISO-8859-1'));

echo "\n-- Multibyte string 1 --\n";
$needle1 = '日本語';
var_dump(mb_stripos($string_mb, $needle1));

echo "\n-- Multibyte string 2 --\n";
$needle2 = 'こんにちは、世界';
var_dump(mb_stripos($string_mb, $needle2));

echo "Done";
?>
--EXPECTF--
*** Testing mb_stripos() : basic functionality***

-- ISO-8859-1 string 1 --
int(4)

-- ISO-8859-1 string 2 --
int(4)

-- ISO-8859-1 string 3 --
int(4)

-- ISO-8859-1 string 4 --
int(4)

-- ISO-8859-1 string 5 --
int(10)

-- ISO-8859-1 string 6 --
int(2)

-- ISO-8859-1 string 7 --
int(2)

-- ISO-8859-1 string 8 --
int(4)

-- ISO-8859-1 string 9 --
bool(false)

-- ISO-8859-1 string 10 --
int(2)

-- ISO-8859-1 string 11 --
int(2)

-- ISO-8859-1 string 12 --
int(4)

-- ISO-8859-1 string 13 --
bool(false)

-- ISO-8859-1 string 14 --
int(10)

-- ISO-8859-1 string 15 --
int(10)

-- ISO-8859-1 string 16 --
int(4)

-- ISO-8859-1 string 17 --
int(12)

-- ISO-8859-1 string 18 --
bool(false)

-- Multibyte string 1 --
int(0)

-- Multibyte string 2 --
bool(false)
Done