当我尝试运行我必须使用但不写的PHP脚本时,我收到此消息.
Deprecated: Function set_magic_quotes_runtime() is deprecated in /opt/lampp/htdocs/webEchange/SiteWeb_V5/inc/fpdf.php on line 1810
Run Code Online (Sandbox Code Playgroud)
这是第1810行:
set_magic_quotes_runtime(0);
Run Code Online (Sandbox Code Playgroud)
如果这是一个已弃用的函数,我可以用它替换它?
非常感谢你!
phi*_*reo 68
检查它是否在第一个.这应该摆脱警告,它将确保如果您的代码在旧版本的PHP上运行,那么魔术引号确实是关闭的.
不要像其他人建议的那样删除那行代码,除非你可以100%确定在PHP 5.3之前代码永远不会运行.
<?php
// Check if magic_quotes_runtime is active
if(get_magic_quotes_runtime())
{
// Deactivate
set_magic_quotes_runtime(false);
}
?>
Run Code Online (Sandbox Code Playgroud)
get_magic_quotes_runtime在PHP 5.3中不推荐使用.
资料来源:http://us2.php.net/get_magic_quotes_runtime/
tes*_*ing 21
我使用FPDF v.1.53并且由于可能的副作用而不想升级.我根据Yacoby使用了以下代码:
1164行:
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
$mqr=get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
}
Run Code Online (Sandbox Code Playgroud)
1203行:
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime($mqr);
}
Run Code Online (Sandbox Code Playgroud)
由于Magic Quotes现在默认关闭(并计划删除),您只需从代码中删除该函数调用即可.
小智 6
在 PHP 7 中,我们可以使用:
ini_set('magic_quotes_runtime', 0);
Run Code Online (Sandbox Code Playgroud)
代替 set_magic_quotes_runtime(0);
你不需要用任何东西替换它。该设置magic_quotes_runtime是在PHP6去除,因此函数调用是不必要的。如果您想保持向后兼容性,最好将其包装在 if 语句中使用version_compare检查phpversion
小智 5
我通过注释掉那行代码来修复我的问题,效果很好。
//if(get_magic_quotes_runtime())
// @set_magic_quotes_runtime(0);
Run Code Online (Sandbox Code Playgroud)