1--TEST-- 2Test mb_substr_count() function : error conditions - pass incorrect number of arguments 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 * Pass an incorrect number of arguments to mb_substr_count() to test behaviour 17 */ 18 19echo "*** Testing mb_substr_count() : error conditions ***\n"; 20 21 22//Test mb_substr_count with one more than the expected number of arguments 23echo "\n-- Testing mb_substr_count() function with more than expected no. of arguments --\n"; 24$haystack = 'string_val'; 25$needle = 'val'; 26$encoding = 'utf-8'; 27$extra_arg = 10; 28var_dump( mb_substr_count($haystack, $needle, $encoding, $extra_arg) ); 29 30// Testing mb_substr_count with one less than the expected number of arguments 31echo "\n-- Testing mb_substr_count() function with less than expected no. of arguments --\n"; 32$haystack = 'string_val'; 33var_dump( mb_substr_count($haystack) ); 34 35echo "Done"; 36?> 37--EXPECTF-- 38*** Testing mb_substr_count() : error conditions *** 39 40-- Testing mb_substr_count() function with more than expected no. of arguments -- 41 42Warning: mb_substr_count() expects at most 3 parameters, 4 given in %s on line %d 43NULL 44 45-- Testing mb_substr_count() function with less than expected no. of arguments -- 46 47Warning: mb_substr_count() expects at least 2 parameters, 1 given in %s on line %d 48NULL 49Done 50