PHP checks the user name and password of a registered user. function-PHP source code

Source: Internet
Author: User
This article will introduce some of my frequently-used php user registration user name and password verification functions, as well: email format, mobile phone number format, QQ number format, telephone number format, including area code, check whether the parameter is Chinese. This article will introduce some of my frequently-used php user registration user name and password verification functions, as well: email format, mobile phone number format, QQ number format, telephone number format, including area code, check whether the parameter is Chinese.

Script ec (2); script

The Code is as follows:
Class Check {
/**
* IsUsername function: checks whether the username format is correct.
* $ Argv is the username parameter to be checked
* $ RegExp is the regular statement to be checked
* Return value: return the username in the username format, not false.
*/
Function IsUsername ($ Argv ){
$ RegExp = '/^ [a-zA-Z0-9 _] {3, 16} $/'; // It consists of uppercase and lowercase letters and numbers and can be 3-16 characters in length.
Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
}

/**
* IsMail function: checks whether the email format is correct.
* Return value: the email is returned in the correct email format, not false.
*/
Function IsMail ($ Argv ){
$ RegExp = '/^ [a-z0-9] [a-z.0-9-_] @ [a-z0-9 _-] (? :. [A-z] {0, 3 }. [a-z] {0, 2} |. [a-z] {0, 3} |. [a-z] {0, 2}) $/I ';
Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
}

/**
* IsSmae function: checks whether the parameter values are the same.
* Return value: true is returned for the same value. false is returned for different values.
*/
Function IsSame ($ ArgvOne, $ ArgvTwo, $ Force = false ){
Return $ Force? $ ArgvOne ===$ ArgvTwo: $ ArgvOne ==$ ArgvTwo;
}

/**
* IsQQ function: checks whether the parameter value complies with the QQ number format.
* Return value: the correct QQ number. The returned QQ number is not false.
*/
Function IsQQ ($ Argv ){
$ RegExp = '/^ [1-9] [0-9] {5, 11} $ /';
Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
}

/**
* IsMobile function: checks whether the parameter value is in the correct Chinese mobile phone number format.
* Return value: indicates the correct mobile phone number. If not, false is returned.
*/
Function IsMobile ($ Argv ){
$ RegExp = '/^ (? : 13 | 15 | 18) [0-9] {9} $ /';
Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
}

/**
* IsTel function: checks whether the value of the parameter is a positive Chinese phone number. The format includes a region code.
* Return value: the correct phone number. The returned phone number is not false.
*/
Function IsTel ($ Argv ){
$ RegExp = '/[0-9] {3,4}-[0-9] {7,8} $ /';
Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
}

/**
* IsNickname function: checks whether the parameter value is in the correct nickname format (Beta)
* Return value: the returned nickname format is correct, not false.
*/
Function IsNickname ($ Argv ){
$ RegExp = '/^ s * $ | ^ c: \ con $ | [%, * "st <> &' ()] | xA1xA1 | xACxA3 | ^ Guest | ^ xD3xCExBFxCD | xB9x43xABxC8/is '; // Copy From DZ
Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
}

/**
* IsChinese function: checks whether the parameter is Chinese.
* Return value: Return parameter, not false
*/
Function IsChinese ($ Argv, $ Encoding = 'utf8 '){
$ RegExp = $ Encoding = 'utf8 '? '/^ [X {4e00}-x {9fa5}] $/U':'/^ ([x80-xFF] [x80-xFF]) $ /';
Return preg_match ($ RegExp, $ Argv )? $ Argv: False;
}
}

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.