1--TEST-- 2Test strspn() function : error conditions 3--FILE-- 4<?php 5/* Prototype : proto int strspn(string str, string mask [, int start [, int len]]) 6 * Description: Finds length of initial segment consisting entirely of characters found in mask. 7 If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars) 8 * Source code: ext/standard/string.c 9 * Alias to functions: none 10*/ 11 12/* 13* Test strspn() : for error conditons 14*/ 15 16echo "*** Testing strspn() : error conditions ***\n"; 17 18// Zero arguments 19echo "\n-- Testing strspn() function with Zero arguments --\n"; 20var_dump( strspn() ); 21 22//Test strspn with one more than the expected number of arguments 23echo "\n-- Testing strspn() function with more than expected no. of arguments --\n"; 24$str = 'string_val'; 25$mask = 'string_val'; 26$start = 2; 27$len = 20; 28 29 30$extra_arg = 10; 31var_dump( strspn($str,$mask,$start,$len, $extra_arg) ); 32 33// Testing strspn withone less than the expected number of arguments 34echo "\n-- Testing strspn() function with less than expected no. of arguments --\n"; 35$str = 'string_val'; 36var_dump( strspn($str) ); 37 38echo "Done" 39?> 40--EXPECTF-- 41*** Testing strspn() : error conditions *** 42 43-- Testing strspn() function with Zero arguments -- 44 45Warning: strspn() expects at least 2 parameters, 0 given in %s on line %d 46NULL 47 48-- Testing strspn() function with more than expected no. of arguments -- 49 50Warning: strspn() expects at most 4 parameters, 5 given in %s on line %d 51NULL 52 53-- Testing strspn() function with less than expected no. of arguments -- 54 55Warning: strspn() expects at least 2 parameters, 1 given in %s on line %d 56NULL 57Done 58