当前位置:Gxlcms > PHP教程 > php正则表达式验证Email地址的例子

php正则表达式验证Email地址的例子

时间:2021-07-01 10:21:17 帮助过:20人阅读

本文介绍下,在php中借助正则表达式来验证Email邮箱地址的例子,有需要的朋友参考下。

php实现验证邮箱地址的例子,很好的应用了php的正则。

1,html部分



php正则验证Email地址

2,php代码部分 RegularExpressionTester.php

string:$string";
echo "
regular expression: $pattern"; if (get_magic_quotes_gpc()){ echo "

"; echo "
Stripping magic quotes...."; $string = stripslashes($string); $pattern = stripslashes($pattern); echo "
string: $string"; echo "
regular expression: $pattern"; } $found = ereg($pattern, $string, $matches); echo "

"; if ($found) { echo "
验证: 成功"; echo "

"; echo "
Components: "; for ($i = 0; $i < count($matches); $i++) { echo "
$matches[$i]"; } } else echo "
验证: 失败"; ?>

人气教程排行