Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我找到了一个用于获取数据库备份的 PHP 脚本,使用此表达式来做某事,该脚本显示对未定义函数 ereg_replace() 的调用此错误,如果我删除此行脚本工作正常...如何将此函数替换$row[$j] = ereg_replace("\n","\\n",$row[$j]);为该脚本运行良好,
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
谁能帮帮我。。
ereg_replace已弃用并从较新版本的 php(7 及更高版本)中删除。
ereg_replace
您必须更新您的代码才能使用preg_replace
preg_replace
$row[$j] = preg_replace("#\n#","\\n",$row[$j]);
ereg_replace() 和 preg_replace() 之间的区别之一是模式必须用定界符括起来:定界符 + 模式 + 定界符,在这种情况下,我们使用#所以我们不必转义/这是通常的情况用过的。
有效分隔符:
/, #, ~, +, %, @, ! , <, >
来自php.net的参考
希望能帮助到你。