在PHP 5.2.14版上使用get_magic_quotes_gpc或PHP版本6上等效 [英] Using get_magic_quotes_gpc on PHP Version 5.2.14 or equivalent for PHP Version 6
本文介绍了在PHP 5.2.14版上使用get_magic_quotes_gpc或PHP版本6上等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们的网站使用的是PHP 5.2.14版
Our site is using PHP Version 5.2.14
最近,我们的托管服务商可能已更改了魔术引号的定义,我想出了建议的解决方法[代码吼叫]
Lately our hoster probably changed magic-quote defenition, and I came up with the suggested solution [code bellow]
- 对于PHP 5.2.14版,此解决方案可以吗?
- 当我们升级到PHP版本6时,我应该改变什么?
// Code:
function fHandleQuotes($s) {
if (get_magic_quotes_gpc())
return ($s);
return (addslashes($s));
}
. . .
// Usage:
. . .
$query = "UPDATE myTable SET myField = '" . fHandleQuotes($_POST['fieldName']) . "'";
. . .
推荐答案
在PHP 6中,magic_quotes将被删除!
现在您可以使用此功能.
In PHP 6 magic_quotes will be removed!
Now you can use this function.
if( ( function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc() ) || ini_get('magic_quotes_sybase') ){
foreach($_GET as $k => $v) $_GET[$k] = stripslashes($v);
foreach($_POST as $k => $v) $_POST[$k] = stripslashes($v);
foreach($_COOKIE as $k => $v) $_COOKIE[$k] = stripslashes($v);
}
这篇关于在PHP 5.2.14版上使用get_magic_quotes_gpc或PHP版本6上等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文