Home  >  Article  >  php教程  >  PHP验证Email和IP地址最简单的方法

PHP验证Email和IP地址最简单的方法

WBOY
WBOYOriginal
2016-06-08 17:21:431205browse

一个PHP验证Email和IP地址例子,非常的简单好用希望对各位朋友会带来帮助哦。

<script>ec(2);</script>

检查一个用户是否输入了一个有效的email地址,最简单的方法就是使用PHP的内建函数filter_var(),它能够检验email地址。

 代码如下 复制代码

filter_var('sgamgee@example.com', FILTER_VALIDATE_EMAIL);

// Returns "sgamgee@example.com". This is a valid email address.

filter_var('sauron@mordor', FILTER_VALIDATE_EMAIL);

// Returns boolean false! This is *not* a valid email address.

?>

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