PHP 5.2 preg_match()编译失败 [英] PHP 5.2 preg_match() compilation failure

查看:512
本文介绍了PHP 5.2 preg_match()编译失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常感谢一些帮助。我的主机服务器端更新导致我的注释表单抛出两个验证错误。第一个是:preg_match()返回警告:preg_match()[function.preg-match]:编译失败:范围在字符类中的偏移在偏移13在[脚本位置这里和行错误] - 第二是主题检查偏移14。

Would very much appreciate some help. My hosts server-side updates have caused my comment form to throw two validation errors. First one is: preg_match() returns Warning: preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 13 in [script location here and line error] - second is on subject check at offset 14.

这样做对电子邮件地址检查:

It does this on the email address check:

if (preg_match('/[^a-zA-Z0-9_-.]/', $_POST['txtEmail']))

和主题检查:

if (preg_match('/[^a-zA-Z0-9:?-. ]/', $_POST['txtSubject']))



不熟悉PHP但可以剪切和粘贴!我的网站的frowey.com和它的联系我们的意见表格开始在托管操作系统更新后抛出一个错误。提前感谢。

I'm not familiar with PHP but can cut and paste! My website's frowey.com and it's the comments form on contact us that's started throwing an error after hosting OS updates. Thanks in advance.

推荐答案

您需要转义 - 它与字符类有特殊的意义,因为错误消息提示。在减号前使用反斜杠:

You need to escape the - minus. It has special meaning with character classes, as the error message hints. Use a backslash before the minus:

preg_match('/[^a-zA-Z0-9_\-.]/'

(或者 - 字符组中的第一个或最后一个事物,因此它失去其特殊功能。)

(Alternatively the - may be the first or last thing in the character group, so it loses its special function.)

这篇关于PHP 5.2 preg_match()编译失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆