How PHP uses the filter function to verify mailboxes, URLs, and IP addresses

Source: Internet
Author: User
Tags filter curl implement string

PHP program to verify the mailbox, IP address or URL in general, we will use regular expressions to deal with, in fact, there are some built-in PHP special validation rules. Here's an example of how to use the PHP built-in filter function to validate Email,ip and URLs.

1, verify the mailbox

$email = ' Alixixi@163.com '; 
$result =filter_var ($email, filter_validate_email); 
Var_dump ($result);
Output: String ' Alixixi@163.com '

2. Verify URL Address

$url = ' http://www.Alixixi.com/'; 
$result =filter_var ($url, filter_validate_url); 
Var_dump ($result);
Output: String ' http://www.Alixixi.com/'

3. Verify IP Address

$url = ' 192.168.0.1 '; 
$result =filter_var ($url, filter_validate_ip); 
Var_dump ($result);
Output: String (11) ' 192.168.0.1 '

The filter function in PHP can also be used to verify floating point numbers, shaping digits, Boolean types, and so on, you can refer to the PHP manual filter function or refer to this site as follows this article

PHP Filter_var () function Filter function

Articles that you may be interested in

    • JS Common function Collection (remove space, verify mailbox, date, positive integer, etc.)
    • PHP using curl to implement multithreaded classes, PHP curl multi-Threaded download pictures
    • PHP window Platform simulation CHECKDNSRR function to detect whether the email is real
    • PHP Filter_var () function Filter function
    • PHP uses Curl functions to implement multi-threaded crawl Web pages and download files
    • PHP gets the full URL address function of the current page, including parameters
    • Summary of methods for using Curl post submission data and get access to Web page data in PHP
    • PHP Verify that the mailbox is correct and effective


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.