1--TEST--
2mb_substr_count()
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--INI--
6output_handler=
7--FILE--
8<?php
9    mb_internal_encoding("EUC-JP");
10    try {
11        var_dump(mb_substr_count("", ""));
12    } catch (\ValueError $e) {
13        echo $e->getMessage() . \PHP_EOL;
14    }
15    try {
16        var_dump(mb_substr_count("��", ""));
17    } catch (\ValueError $e) {
18        echo $e->getMessage() . \PHP_EOL;
19    }
20
21    var_dump(mb_substr_count("", "��"));
22    var_dump(mb_substr_count("", "��"));
23    var_dump(mb_substr_count("", chr(0)));
24
25    $a = str_repeat("abcacba", 100);
26    var_dump(@mb_substr_count($a, "bca"));
27
28    $a = str_repeat("��������������", 100);
29    $b = "������";
30    var_dump(@mb_substr_count($a, $b));
31
32    $to_enc = "UTF-8";
33    var_dump(@mb_substr_count(mb_convert_encoding($a, $to_enc),
34                              mb_convert_encoding($b, $to_enc), $to_enc));
35
36    $to_enc = "Shift_JIS";
37    var_dump(@mb_substr_count(mb_convert_encoding($a, $to_enc),
38                              mb_convert_encoding($b, $to_enc), $to_enc));
39
40    $a = str_repeat("abcacbabca", 100);
41    var_dump(@mb_substr_count($a, "bca"));
42?>
43--EXPECT--
44mb_substr_count(): Argument #2 ($needle) must not be empty
45mb_substr_count(): Argument #2 ($needle) must not be empty
46int(0)
47int(0)
48int(0)
49int(100)
50int(100)
51int(100)
52int(100)
53int(200)
54