PHP checks the user name and password of a registered user.

Source: Internet
Author: User
The code is as follows: Copy code
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;
        }   
}
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.