警告:preg_match()[function.preg-match]:未知修饰符'v' [英] Warning: preg_match() [function.preg-match]: Unknown modifier 'v'
本文介绍了警告:preg_match()[function.preg-match]:未知修饰符'v'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的wordpress博客中,关于同一行代码,我一直收到约20次此错误.这是不断出现错误的代码行.
I keep getting this error about 20 times in my wordpress blog about the same line of code. Here is the line of code that keeps getting the error.
if ( preg_match( '/' . $id_base . '-([0-9]+)$/', $widget_id, $matches ) )
$number = max($number, $matches[1]);
有什么问题吗?
推荐答案
如果字符串$id_base
中包含/
,则正则表达式将中断,因为您正在使用/
作为正则表达式定界符.
Your regex will break if the string $id_base
has a /
in it as you are using /
as the regex delimiter.
要解决此问题,请在$id_base
上将preg_quote
用作:
To fix this use preg_quote
on $id_base
as:
if (preg_match('/'. preg_quote($id_base,'/').'-([0-9]+)$/', .....) {
这篇关于警告:preg_match()[function.preg-match]:未知修饰符'v'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文