Php user name, password, phone number, legal judgment code article has three common functions: Determine whether the user name is valid and whether the user password is valid, determine whether the phone number is valid. these three functions are indispensable during development. the instance code is as follows:
// Function name: CheckUser ($ C_user)
// Usage: determines whether the user name is valid
// Parameter: $ C_user (user name to be detected)
// Return value: Boolean
// Standby Note: 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)
// Usage: determines whether the password is valid.
// Parameter: $ C_passwd (password to be detected)
// Return value: Boolean
// Standby Note: 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)
// Usage: determines whether the phone number is a legal phone number.
// Parameter: $ C_telephone (phone number to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
Function CheckTelephone ($ C_telephone)
{
If (! Ereg ("^ [+]? [0-9] + ([xX-] [0-9] +) * $ ", $ C_telephone) return false;
Return true;
}