在升级到php7之后,preg_match():编译失败:丢失)在偏移量14处

时间:2016-08-15 06:57:33

标签: php mysql

请,我需要帮助才能解决此问题。我将服务器升级到php7后收到此警告。

} elseif (strlen($phrase) == stripos($phrase, '*') + 1) {
                $phrase = str_replace('*', '', $phrase);
                $collapsed_phrase = explode(' ', $phrase);
                if (count($collapsed_phrase) > 1) {
                    $pattern = '/\b(' . $phrase . '[a-zA-Z0-9]*)/i';
                    $res = preg_match_all($pattern, $data['adtitle'], $mass);
            }

我的错误堆栈指向上面的块。 提前致谢

1 个答案:

答案 0 :(得分:1)

问题似乎是$phrase中的输入包含特殊字符。要确保自定义输入不会导致此问题,请在将输入插入正则表达式时始终使用preg_quote