PHP Data validation

Source: Internet
Author: User

<?PHP/**************** Implementing data validation **********************8*//** * to detect Arabic numerals * * only allowed to enter Arabic numerals * * @access public * @param numeric parameters*/    functionCheckisnumeric ($numeric)    {        return!Preg_match("/^(\-?) (\d+) $/",Trim($numeric)) ?false:true; }    /** * detect non-numeric characters * * Only allow input of non-numeric characters * * @access public * @param string parameter*/    functionCheckisstring ($string)    {        return!Preg_match("/^(\-?) (\d+) $/",Trim($string),$matches) ?false:true; }    /** * Detect non-numeric and alphabetic combination characters (with mid-bar, down-stroke) * * Only allow input of alphanumeric characters (with middle bars, lower strokes) * * @access public * @param string parameter /c5>*/    functionCheckisstringandnumericplus ($string)    {        return!Preg_match("/^ ([_-a-za-z0-9]) +$/i",$string) ?FALSE:TRUE; }    /** * Detect mobile phone number * * detect mobile phone number * * @access public * @param mobile phone number*/    functionCheckmobile ($mobile)    {        return(!Preg_match("/^ (13|15|18) [0-9]{9}$/",Trim($mobile))) ?false:true; }    /** * Detect Phone number * * detect phone number * * @access public * @param phone phone number*/    functionCheckphone ($phone)    {        return!Preg_match("/^ ([0-9]| [-]) +$/",Trim($phone)) ?false:true; }    /** * Check URL format * * Check URL format * * @access public * @param URL URL address*/    functionCheckurl ($url)    {        if(Preg_match('/^ (HTTP|HTTPS): \/\/[a-za-z0-9]+\. [a-za-z0-9]+[\/=\?%\ -&_~ ' @[\]\ ': +!] * ([^<>\]) *$/',$url)) {            return true; } Else {            return false; }    }    /** * Check email format * * Check email format * * @access public * @param Email*/    functionCheckemail ($email)    {        return( !Preg_match("/^ ([a-z0-9\+_\-]+) (\.[ a-z0-9\+_\-]+) *@ ([a-z0-9\-]+\.) +[a-z]{2,6}$/ix ",$email)) ?FALSE:TRUE; }?>

PHP Data validation

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.