Original Determines whether the mailbox, URL, and IP address formats are compliant with regular expressions. I later learned that in PHP you can also use the built-in function library filter to complete these functions, the following to share with you
1, verify the mailbox code as follows: $email = ' jb51@qq.com '; $result = Filter_var ($email, Filter_validate_email); Var_dump ($result); String "jb51@qq.com" 2, the authentication URL address code is as follows: $url = "Http://www.jb51.net"; $result = Filter_var ($url, Filter_validate_url); Var_dump ($result); String "Http://www.jb51.net" 3, verify IP address code as follows: $url = "192.168.1.110"; $result = Filter_var ($url, FILTER_VALIDATE_IP); Var_dump ($result); As a reference to the 192.168.1.110 Value, this method can also be used to validate IPv6. The code is as follows: $url = "2001:db8:2de::e13"; $result = Filter_var ($url, FILTER_VALIDATE_IP); Var_dump ($result); String (2001:db8:2de::e13) 4, verify that the value is an integer, and within an integer range code is as follows: $i = ' 010 '; $result = Filter_var ( $i, Filter_validate_int, //Set checksum value range Array ( ' options ' => array (' Min_range ' => 1, ' Max_range ' =>) )); Var_dump ($result);//bool (false) PHA variable of p is a weak type, and if you do not use a filter, it will be true if you are using more than or less than the symbol. Code as follows: $i = ' 010 '; $result = $i >= 1 && $i <= 100; Var_dump ($result);//bool (true) 5, verify the floating-point number code as follows: $float = 12.312; $result = Filter_var ($float, filter_validate_float); Var_dump ($result); Float (12.312)