PHP5- Preg_Match()错误

时间:2014-10-02 14:09:50

标签: php html

我意识到这个错误还有其他问题,但是我无法读懂PHP的生活。

错误: 警告:preg_match()[function.preg-match]:在第87行的/srv/disk11/1731569/www/straightpathbible.dx.am/prayer.php中清空正则表达式

警告:preg_match()[function.preg-match]:在第87行的/srv/disk11/1731569/www/straightpathbible.dx.am/prayer.php中清空正则表达式

警告:mail()[function.mail]:无法执行邮件传递程序' / usr / local / bin / sendmail -oi -t'在第88行的/srv/disk11/1731569/www/straightpathbible.dx.am/prayer.php

我的网站(供参考): http://straightpathbible.dx.am/prayer.php

代码:

     if (email_is_valid($youremail) && !preg_match("\r",$youremail) && !preg_match("\n",$youremail) && $yourname != "" && $yourmessage != "" &&          substr(md5($user_answer),5,10) === $answer) {
     mail($to,$subject,$message,$headers);
    $yourname = '';
    $youremail = '';
    $yourmessage = '';
    echo '<p style="color: blue;">'.$contact_submitted.'</p>'; }

任何帮助都会很棒!谢谢你的期待!

1 个答案:

答案 0 :(得分:3)

您收到警告,因为正则表达式应该有分隔符,即"/\r/"而不是"\r"

也就是说,改为使用strpbrk()

if (email_is_valid($youremail) && strpbrk($youremail, "\r\n") === false ...

那么,email_is_valid()不应该抓住那个吗?没有听说过包含换行符的有效电子邮件地址。