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