php - preg_match() : Compilation failed: missing ) at offset 14 after i upgraded to php7

标签 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);
            }

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

最佳答案

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

关于php - preg_match() : Compilation failed: missing ) at offset 14 after i upgraded to php7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38950590/

相关文章:

php - 如何转义 MYSQL 查询中的引号?

php - Laravel 5.4 查询检查数组的键/值之间是否存在值

MySQL 5.6 - 如何在没有密码提示的情况下使用 mysqldump 在 Windows 上创建备份

php - 使用取消链接功能删除文件php

php - 使用键作为数字 PHP 访问对象

php - 从 PHP 回显 javascript

php - IIS 服务器,如何为 Laravel 5 配置 url 重写?

mysql - 使用正则表达式删除表 - MySQL

java - 只是 'DELETE' 请求方法不支持

php - 协助在 mysql 中使用 php 中的更新方法