Php user name, password, phone number, legal judgment code

Source: Internet
Author: User
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;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.