校验url,email和ip的PHP代码
时间:2021-07-01 10:21:17
帮助过:29人阅读
-
- function is_valid_url($url){
- $p1 ='/(http|https|ftp):\/\/[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(\/.*)?$/i';
- return preg_match($p1, $url);
- }
-
- function is_valid_email($email){
- if (filter_var($email, FILTER_VALIDATE_EMAIL))
- return true;
- else
- return false;
- }
-
- function is_valid_ip($ip){
- if (filter_var($ip, FILTER_VALIDATE_IP))
- return true;
- else
- return false;
- }
-
- ?>
|
email, url, PHP