1--TEST--
2Test substr_count() function (variation - 2)
3--FILE--
4<?php
5
6echo "\n*** Testing possible variations ***\n";
7echo "\n-- complex strings containing other than 7-bit chars --\n";
8$str = chr(128).chr(129).chr(128).chr(256).chr(255).chr(254).chr(255);
9var_dump(substr_count($str, chr(128)));
10var_dump(substr_count($str, chr(255)));
11var_dump(substr_count($str, chr(256)));
12
13echo "\n-- heredoc string --\n";
14$string = <<<EOD
15abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
16abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
17acdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
18acdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
19abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
20abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
21abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
22abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
23EOD;
24var_dump(substr_count($string, "abcd"));
25var_dump(substr_count($string, "1234"));
26
27echo "\n-- heredoc null string --\n";
28$str = <<<EOD
29EOD;
30var_dump(substr_count($str, "\0"));
31var_dump(substr_count($str, "\x000"));
32var_dump(substr_count($str, "0"));
33
34echo "Done\n";
35
36?>
37--EXPECTF--
38*** Testing possible variations ***
39
40-- complex strings containing other than 7-bit chars --
41int(2)
42int(2)
43int(1)
44
45-- heredoc string --
46int(14)
47int(16)
48
49-- heredoc null string --
50int(0)
51int(0)
52int(0)
53Done
54