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

PHP code to verify url, email and ip

WBOY
WBOYOriginal
2016-07-25 08:42:491098browse
  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


Statement:
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