The article has three commonly used functions, which are to determine whether it is a legal username, to determine whether it is a legal user password, and to determine whether it is a legal phone number. These three functions are indispensable in development. The example code is as follows:
// Function name: CheckUser($C_user)
// Function: Determine whether it is a legal user name
// Parameters: $C_user (user name to be detected)
// Return value: Boolean value
//Remarks: None
function CheckUser($C_user)
{
if (!CheckLengthBetween($C_user, 4, 20)) return false; / /width check
if (!ereg("^[_a-zA-Z0-9]*$", $C_user)) return false; //Special character check
return true;
}
// Function name: CheckPassword($C_passwd)
// Function: Determine whether it is a legal user password
// Parameters: $C_passwd (password to be detected)
// Return Value: Boolean value
//Remarks: None
/
function CheckPassword($C_passwd)
{
if (!CheckLengthBetween($C_passwd, 4, 20) ) return false; //Width detection
if (!ereg("^[_a-zA-Z0-9]*$", $C_passwd)) return false; //Special character detection
return true ;
}
// Function name: CheckTelephone($C_telephone)
// Function: Determine whether it is a legal phone number
// Parameter: $C_telephone (to be detected Phone number)
// Return value: Boolean value
// Remarks: None
//----------------------------- -------------------------------------------------- -------------
function CheckTelephone($C_telephone)
{
if (!ereg("^[+]?[0-9]+([xX -][0-9]+)*$", $C_telephone)) return false;
return true;
}