Home  >  Article  >  Backend Development  >  php username, password, phone number, legal judgment code

php username, password, phone number, legal judgment code

高洛峰
高洛峰Original
2016-11-29 15:48:011578browse

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;

}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn