The article has three commonly used functions, respectively, is to determine whether it is a legitimate user name, to determine whether it is a legitimate user password, determine whether it is a legitimate telephone number, these three is the development of the function, the example code is as follows:
Function name: CheckUser ($C _user)
Role: Determine whether a valid user name
Parameters: $C _user (user name to be detected)
Return Value: Boolean value
Remark: None
function CheckUser ($C _user)
{
if (! Checklengthbetween ($C _user, 4,)) return false; Width test
if (!ereg ("^[_a-za-z0-9]*$", $C _user)) return false; Special character test
return true;
}
Function name: Checkpassword ($C _passwd)
Role: Determine if the password is a valid user
Parameters: $C _passwd (password to be detected)
Return Value: Boolean value
Remark: None
/
function Checkpassword ($C _passwd)
{
if (! Checklengthbetween ($C _passwd, 4,)) return false; Width detection
if (!ereg ("^[_a-za-z0-9]*$", $C _passwd)) return false; Special character detection
return true;
}
Function name: Checktelephone ($C _telephone)
Role: Determine whether a legal phone number
Parameters: $C _telephone (phone number to be detected)
Return Value: Boolean value
Remark: None
//-----------------------------------------------------------------------------------
function Checktelephone ($C _telephone)
{
if (!ereg ("^[+]?[ 0-9]+ ([xx-][0-9]+) *$ ", $C _telephone)) return false;
return true;
}