1--TEST--
2Test substr_count() function (error conditions)
3--FILE--
4<?php
5
6echo "\n*** Testing error conditions ***\n";
7$str = 'abcdefghik';
8
9/* Zero argument */
10var_dump( substr_count() );
11
12/* more than expected no. of args */
13var_dump( substr_count($str, "t", 0, 15, 30) );
14
15/* offset before start */
16var_dump(substr_count($str, "t", -20));
17
18/* offset > size of the string */
19var_dump(substr_count($str, "t", 25));
20
21/* Using offset and length to go beyond the size of the string:
22   Warning message expected, as length+offset > length of string */
23var_dump( substr_count($str, "i", 5, 7) );
24
25/* Invalid offset argument */
26var_dump( substr_count($str, "t", "") );
27
28/* length too small */
29var_dump( substr_count($str, "t", 2, -20) );
30
31echo "Done\n";
32
33?>
34--EXPECTF--
35*** Testing error conditions ***
36
37Warning: substr_count() expects at least 2 parameters, 0 given in %s on line %d
38NULL
39
40Warning: substr_count() expects at most 4 parameters, 5 given in %s on line %d
41NULL
42
43Warning: substr_count(): Offset not contained in string in %s on line %d
44bool(false)
45
46Warning: substr_count(): Offset not contained in string in %s on line %d
47bool(false)
48
49Warning: substr_count(): Invalid length value in %s on line %d
50bool(false)
51
52Warning: substr_count() expects parameter 3 to be integer, string given in %s on line %d
53NULL
54
55Warning: substr_count(): Invalid length value in %s on line %d
56bool(false)
57Done
58