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