1--TEST--
2Test mb_stristr() function : basic functionality
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7echo "*** Testing mb_stristr() : basic functionality ***\n";
8
9mb_internal_encoding('UTF-8');
10
11$string_ascii = 'abcdef';
12$needle_ascii_upper = "BCD";
13$needle_ascii_mixed = "bCd";
14$needle_ascii_lower = "bcd";
15
16//Greek string in lower case UTF-8
17$string_mb = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J');
18$needle_mb_upper = base64_decode('zpzOnc6ezp8=');
19$needle_mb_lower = base64_decode('zrzOvc6+zr8=');
20$needle_mb_mixed = base64_decode('zpzOnc6+zr8=');
21
22echo "\n-- ASCII string: needle exists --\n";
23var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_upper, false, 'ISO-8859-1')));
24var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_lower)));
25var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_mixed, true)));
26
27
28echo "\n-- ASCII string: needle doesn't exist --\n";
29var_dump(mb_stristr($string_ascii, '123'));
30
31echo "\n-- Multibyte string: needle exists --\n";
32var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_upper)));
33var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_lower, false, 'utf-8')));
34var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_mixed, true)));
35
36
37echo "\n-- Multibyte string: needle doesn't exist --\n";
38$needle2 = base64_decode("zrzOvs6/");
39var_dump(mb_stristr($string_mb, $needle2));
40
41?>
42--EXPECT--
43*** Testing mb_stristr() : basic functionality ***
44
45-- ASCII string: needle exists --
46string(10) "6263646566"
47string(10) "6263646566"
48string(2) "61"
49
50-- ASCII string: needle doesn't exist --
51bool(false)
52
53-- Multibyte string: needle exists --
54string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89"
55string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89"
56string(44) "ceb1ceb2ceb3ceb4ceb5ceb6ceb7ceb8ceb9cebacebb"
57
58-- Multibyte string: needle doesn't exist --
59bool(false)
60