Common form verification classes in PHP dynamic web page programs

Source: Internet
Author: User
// Data display restoration data pattern important for content output input values can be strings or one/two-dimensional arrays // before performing this method, data_revert (), the form content does not need to be restored to form verification classes commonly used in PHP dynamic web page development.

Class class_post
{
// Verify whether it is a combination of letters and numbers with a specified length
Function fun_text1 ($ num1, $ num2, $ str)
{
Return (preg_match ('/^ [a-zA-Z0-9] {'. $ num1. ','. $ num2. '} $/', $ str ))? True: false;
}

// Verify whether it is a number of the specified length
Function fun_text2 ($ num1, $ num2, $ str)
{
Return (preg_match ('/^ [0-9] {'. $ num1. ','. $ num2. '} $/I', $ str ))? True: false;
}
// Verify whether the Chinese character is of the specified length
Function fun_font ($ num1, $ num2, $ str)
{
// Preg_match ('/^ [\ xa0-\ xff] {1, 4} $/', $ string );
Return (preg_match ('/^ ([\ x81-\ xfe] [\ x40-\ xfe]) {'. $ num1 .','. $ num2. '} $/', $ str ))? True: false;
}
// Verify the ID card number
Function fun_status ($ str)
{
Return (preg_match ('/(^ ([\ d] {15} | [\ d] {18} | [\ d] {17} x) $ )/', $ str ))? True: false;
}

// Verify the email address
Function fun_email ($ str ){
Return (preg_match ('/^ [_\. 0-9a-z-] @ ([0-9a-z] [0-9a-z-] \.) [a-z] {2, 4} $/', $ str ))? True: false;
}
// Verify the phone number
Function fun_phone ($ str)
{

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.