Php user registration common detection class _ PHP Tutorial

Source: Internet
Author: User
Common php user registration detection classes .? Php *** Check class * ClassCheck {*** 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

  1. /**
  2. * Check
  3. */
  4. Class Check {
  5. /**
  6. * IsUsername function: checks whether the username format is correct.
  7. * $ Argv is the username parameter to be checked
  8. * $ RegExp is the regular statement to be checked
  9. * Return value: return the username in the username format, not false.
  10. */
  11. Function IsUsername ($ Argv ){
  12. $ RegExp =/^ [a-zA-Z0-9 _] {3, 16} $/; // It consists of uppercase and lowercase letters and numbers and can be 3-16 characters in length.
  13. Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
  14. }
  15. /**
  16. * IsMail function: checks whether the email format is correct.
  17. * Return value: the email is returned in the correct email format, not false.
  18. */
  19. Function IsMail ($ Argv ){
  20. $ 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;
  21. Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
  22. }
  23. /**
  24. * IsSmae function: checks whether the parameter values are the same.
  25. * Return value: true is returned for the same value. false is returned for different values.
  26. */
  27. Function IsSame ($ ArgvOne, $ ArgvTwo, $ Force = false ){
  28. Return $ Force? $ ArgvOne ===$ ArgvTwo: $ ArgvOne ==$ ArgvTwo;
  29. }
  30. /**
  31. * IsQQ function: checks whether the parameter value complies with the QQ number format.
  32. * Return value: the correct QQ number. the returned QQ number is not false.
  33. */
  34. Function IsQQ ($ Argv ){
  35. $ RegExp =/^ [1-9] [0-9] {5, 11} $ /;
  36. Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
  37. }
  38. /**
  39. * IsMobile function: checks whether the parameter value is in the correct Chinese mobile phone number format.
  40. * Return value: indicates the correct mobile phone number. if not, false is returned.
  41. */
  42. Function IsMobile ($ Argv ){
  43. $ RegExp =/^ (? : 13 | 15 | 18) [0-9] {9} $ /;
  44. Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
  45. }
  46. /**
  47. * IsTel function: checks whether the value of the parameter is a positive Chinese phone number. the format includes a region code.
  48. * Return value: the correct phone number. the returned phone number is not false.
  49. */
  50. Function IsTel ($ Argv ){
  51. $ RegExp =/[0-9] {3, 4}-[0-9] {7, 8} $ /;
  52. Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
  53. }
  54. /**
  55. * IsNickname function: checks whether the parameter value is in the correct nickname format (Beta)
  56. * Return value: the returned nickname format is correct, not false.
  57. */
  58. Function IsNickname ($ Argv ){
  59. $ RegExp =/^ s * $ | ^ c: concon $ | [%, * "s <> & \ ()] | xA1xA1 | xACxA3 | ^ Guest | ^ xD3xCExBFxCD | xB9x43xABxC8/is; // Copy From DZ
  60. Return preg_match ($ RegExp, $ Argv )? $ Argv: false;
  61. }
  62. /**
  63. * IsChinese function: checks whether the parameter is Chinese.
  64. * Return value: return parameter, not false
  65. */
  66. Function IsChinese ($ Argv, $ Encoding = utf8 ){
  67. $ RegExp = $ Encoding = utf8? /^ [X {4e00}-x {9fa5}] $/u:/^ ([x80-xFF] [x80-xFF]) $ /;
  68. Return preg_match ($ RegExp, $ Argv )? $ Argv: False;
  69. }
  70. }
  71. ?>

Http://www.bkjia.com/PHPjc/486137.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486137.htmlTechArticle? Php/*** Check Class */Class Check {/*** IsUsername function: check whether the username format * $ Argv is the username parameter to be checked * $ RegExp is the regular statement to be checked...

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.