Pra*_*dip 31 php deprecated ereg
我写了以下PHP代码:
$input="menu=1&type=0&";
print $input."<hr>".ereg_replace('/&/', ':::', $input);
Run Code Online (Sandbox Code Playgroud)
运行上面的代码后,它会发出以下警告:
不推荐使用:不推荐使用函数ereg_replace()
我该如何解决此警告.
Que*_*tin 41
切换到preg_replace
文档并更新表达式以使用preg语法(PCRE)而不是ereg语法(POSIX),其中存在差异文档(正如它在ereg_replace
Docs手册中所说的那样).
小智 31
print $input."<hr>".ereg_replace('/&/', ':::', $input);
Run Code Online (Sandbox Code Playgroud)
变
print $input."<hr>".preg_replace('/&/', ':::', $input);
Run Code Online (Sandbox Code Playgroud)
更多例子:
$mytext = ereg_replace('[^A-Za-z0-9_]', '', $mytext );
Run Code Online (Sandbox Code Playgroud)
改为
$mytext = preg_replace('/[^A-Za-z0-9_]/', '', $mytext );
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
164353 次 |
最近记录: |