Home > Backend Development > PHP Tutorial > PHP code to verify url, email and ip

PHP code to verify url, email and ip

WBOY
Release: 2016-07-25 08:42:49
Original
1122 people have browsed it
  1. function is_valid_url($url){
  2. $p1 ='/(http|https|ftp)://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$/i';
  3. return preg_match($p1, $url);
  4. }
  5. function is_valid_email($email){
  6. if (filter_var($email, FILTER_VALIDATE_EMAIL))
  7. return true;
  8. else
  9. return false;
  10. }
  11. function is_valid_ip($ip){
  12. if (filter_var($ip, FILTER_VALIDATE_IP))
  13. return true;
  14. else
  15. return false;
  16. }
  17. ?>
复制代码

email, url, PHP


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template