import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / substr_count_variation_001.php
blobf308ed644cb9e5cde34b7dc940ebeb667919d20c
1 <?php
3 echo "\n*** Testing possible variations ***\n";
4 echo "-- 3rd or 4th arg as string --\n";
5 $str = "this is a string";
6 var_dump( substr_count($str, "t", "5") );
7 var_dump( substr_count($str, "t", "5", "10") );
8 var_dump( substr_count($str, "i", "5t") );
9 var_dump( substr_count($str, "i", "5t", "10t") );
11 echo "\n-- 3rd or 4th arg as NULL --\n";
12 var_dump( substr_count($str, "t", "") );
13 var_dump( substr_count($str, "T", "") );
14 var_dump( substr_count($str, "t", "", 15) );
15 var_dump( substr_count($str, "I", NULL) );
16 var_dump( substr_count($str, "i", NULL, 10) );
18 echo "\n-- overlapped substrings --\n";
19 var_dump( substr_count("abcabcabcabcabc", "abca") );
20 var_dump( substr_count("abcabcabcabcabc", "abca", 2) );
22 echo "\n-- complex strings containing other than 7-bit chars --\n";
23 $str = chr(128).chr(129).chr(128).chr(256).chr(255).chr(254).chr(255);
24 var_dump(substr_count($str, chr(128)));
25 var_dump(substr_count($str, chr(255)));
26 var_dump(substr_count($str, chr(256)));
28 echo "\n-- heredoc string --\n";
29 $string = <<<EOD
30 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
31 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
32 acdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
33 acdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
34 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
35 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
36 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
37 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
38 EOD;
39 var_dump(substr_count($string, "abcd"));
40 var_dump(substr_count($string, "1234"));
42 echo "\n-- heredoc null string --\n";
43 $str = <<<EOD
44 EOD;
45 var_dump(substr_count($str, "\0"));
46 var_dump(substr_count($str, "\x000"));
47 var_dump(substr_count($str, "0"));
49 echo "Done\n";