5

关于同一行代码,我在我的 wordpress 博客中不断收到大约 20 次此错误。这是不断收到错误的代码行。

if ( preg_match( '/' . $id_base . '-([0-9]+)$/', $widget_id, $matches ) )
        $number = max($number, $matches[1]);

有什么问题?

4

1 回答 1

5

如果字符串$id_base中有 a/在您/用作正则表达式分隔符时,您的正则表达式将中断。

将此使用修复preg_quote$id_base

if (preg_match('/'. preg_quote($id_base,'/').'-([0-9]+)$/', .....) {
于 2011-03-16T04:36:25.167 回答