例:
/**
* This function will determine whether or not one string starts with another string.
* @param string $haystack
The string that needs to be checked.
* @param string $needle
The string that is being checked for.
* @param boolean $case[optional]
Set to false to ignore case(capital or normal characters)
* @return boolean
If the $haystack string does start with the $needle string, the return will be true. False if not.
*/
function endsWith($haystack,$needle,$case=true) {
if($case){return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);}
return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);
}
默认情况下,可选参数设置为true.我想指出文档中的默认设置.有没有一个标准的做法,或者我必须在描述中提到它?