日期:2014-05-17  浏览次数:20677 次

正则表达式验证老是失败
<body>
        <?php
        if(!empty($_POST[sub]))
        {
            
        if(ereg("\d{10}", $_POST[username]))
        
        {echo "验证通过。";}
        else
        {echo "验证失败";}
        }
        ?>
        <form action="" method="post">
    用户名<input type="text" name="username"><br>
    <input type="submit" name="sub" value="提交">
</form>
    </body>

------解决方案--------------------
if(preg_match("/^\d{10}$/", $_POST[username]))
------解决方案--------------------
Deprecated:  Function ereg() is deprecated 
Deprecated 已过时