当我尝试运行我必须使用但未编写的 php 脚本时收到此消息。
Deprecated: Function set_magic_quotes_runtime() is deprecated in /opt/lampp/htdocs/webEchange/SiteWeb_V5/inc/fpdf.php on line 1810
这是第 1810 行:
set_magic_quotes_runtime(0);
如果这是一个不推荐使用的功能,我可以用什么替换它?
非常感谢!
当我尝试运行我必须使用但未编写的 php 脚本时收到此消息。
Deprecated: Function set_magic_quotes_runtime() is deprecated in /opt/lampp/htdocs/webEchange/SiteWeb_V5/inc/fpdf.php on line 1810
这是第 1810 行:
set_magic_quotes_runtime(0);
如果这是一个不推荐使用的功能,我可以用什么替换它?
非常感谢!
先看看有没有开。这应该可以消除警告,并且可以确保如果您的代码在旧版本的 PHP 上运行,魔术引号确实是关闭的。
不要只删除其他人建议的那行代码,除非您可以 100% 确定该代码永远不会在 PHP 5.3 之前的任何东西上运行。
<?php
// Check if magic_quotes_runtime is active
if(get_magic_quotes_runtime())
{
// Deactivate
set_magic_quotes_runtime(false);
}
?>
get_magic_quotes_runtime
在 PHP 5.3 中不推荐使用。
来源:http ://us2.php.net/get_magic_quotes_runtime/
我使用了 FPDF v. 1.53 并且由于可能的副作用而不想升级。我根据 Yacoby 使用了以下代码:
第 1164 行:
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
$mqr=get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
}
第 1203 行:
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime($mqr);
}
由于 Magic Quotes 现在默认关闭(并在 PHP v8 中删除),您可以从代码中删除该函数调用。
你不需要用任何东西替换它。magic_quotes_runtime
PHP6中删除了该设置,因此不需要函数调用。如果您想保持向后兼容性,最好将其包装在 if 语句中,使用version_compare检查phpversion
升级到 FPDF 1.6 版。
在 PHP 7 中,我们可以使用:
ini_set('magic_quotes_runtime', 0);
代替set_magic_quotes_runtime(0);
ini_set('magic_quotes_runtime', 0)
我猜。
将这些代码添加到脚本的顶部以解决问题
@set_magic_quotes_runtime(false);
ini_set('magic_quotes_runtime', 0);
阵风在函数前添加前缀“@”为@set_magic_quotes_runtime(0);php 5.4 不再支持,请勿删除或禁用该功能
我通过注释掉那行代码来修复我的问题,它工作正常。
//if(get_magic_quotes_runtime())
// @set_magic_quotes_runtime(0);
更新此功能:
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime(0);
}
else {
ini_set('magic_quotes_runtime', 0);
}
$magic_quotes = get_magic_quotes_runtime();
$file_buffer = fread($fd, filesize($path));
$file_buffer = $this->EncodeString($file_buffer, $encoding);
fclose($fd);
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime($magic_quotes);
}
else {
ini_set('magic_quotes_runtime', $magic_quotes);
}
}
return $file_buffer;