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

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

}

  • 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.