1--TEST--
2Test mb_substr_count() function : basic functionality
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip');
6function_exists('mb_substr_count') or die("skip mb_substr_count() is not available in this build");
7?>
8--FILE--
9<?php
10/* Prototype  : int mb_substr_count(string $haystack, string $needle [, string $encoding])
11 * Description: Count the number of substring occurrences
12 * Source code: ext/mbstring/mbstring.c
13 */
14
15/*
16 * Test Basic functionality of mb_substr_count
17 */
18
19echo "*** Testing mb_substr_count() : basic functionality ***\n";
20
21$string_ascii = 'This is an English string. 0123456789.';
22
23$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
24$needle_mb1 = base64_decode('44CC');
25$needle_mb2 = base64_decode('44GT44KT44Gr44Gh44Gv44CB5LiW55WM');
26
27echo "\n-- ASCII String --\n";
28var_dump(mb_substr_count($string_ascii, 'is'));
29var_dump(mb_substr_count($string_ascii, 'hello, world'));
30
31echo "\n-- Multibyte String --\n";
32var_dump(mb_substr_count($string_mb, $needle_mb1));
33var_dump(mb_substr_count($string_mb, $needle_mb2));
34
35echo "Done";
36?>
37--EXPECTF--
38*** Testing mb_substr_count() : basic functionality ***
39
40-- ASCII String --
41int(3)
42int(0)
43
44-- Multibyte String --
45int(2)
46int(0)
47Done
48