Php 为什么我要得到这个数组到字符串的转换通知
我正在使用eCard程序发送活动邀请,并收到以下通知: 注意:中的数组到字符串转换 /nfs/c07/h01/mnt/108712/domains/christmasnativity.org/html/ecard/include/common.inc.php 第32行 以下是第29行到第33行的代码:Php 为什么我要得到这个数组到字符串的转换通知,php,Php,我正在使用eCard程序发送活动邀请,并收到以下通知: 注意:中的数组到字符串转换 /nfs/c07/h01/mnt/108712/domains/christmasnativity.org/html/ecard/include/common.inc.php 第32行 以下是第29行到第33行的代码: /* Clean up request: Remove magic quotes, if the setting is enabled. */ if (get_magic_quotes_gpc()
/* Clean up request: Remove magic quotes, if the setting is enabled. */
if (get_magic_quotes_gpc()) {
foreach($_REQUEST as $name => $value)
$_REQUEST[$name] = stripslashes($value);
}
有什么线索可能导致此错误通知
谢谢。请求中的一个值是数组。如果变量使用的名称如
foo[]
请求中的一个值是数组,则可能会发生这种情况。如果变量使用诸如foo[]
之类的名称(如Ignacio Vazquez Abrams所说,$value
中的一个是数组),则可能发生这种情况。您可以使用以下内容查看什么是数组(假设您正在/可以将结果输出到可以看到它们的地方):
正如Ignacio Vazquez Abrams所说,
$value
中的一个是数组。您可以使用以下内容查看什么是数组(假设您正在/可以将结果输出到可以看到它们的地方):
您可以避免在这样的阵列上运行stripslashes
if (get_magic_quotes_gpc()) {
foreach($_REQUEST as $name => $value)
if(!is_array($value)){
$_REQUEST[$name] = stripslashes($value);
}
}
但是数组$value
中的值不会被剥离
更完整的解决方案如下:
if (get_magic_quotes_gpc())
{
strip_slashes_recursive($_REQUEST);
}
function strip_slashes_recursive(&$array)
{
foreach ($array as $key => $value)
{
if (is_array ($value))
{
strip_slashes_recursive ($array[$key]);
}
else
{
$array[$key] = stripslashes($value);
}
}
}
您可以避免在这样的阵列上运行stripslashes
if (get_magic_quotes_gpc()) {
foreach($_REQUEST as $name => $value)
if(!is_array($value)){
$_REQUEST[$name] = stripslashes($value);
}
}
但是数组$value
中的值不会被剥离
更完整的解决方案如下:
if (get_magic_quotes_gpc())
{
strip_slashes_recursive($_REQUEST);
}
function strip_slashes_recursive(&$array)
{
foreach ($array as $key => $value)
{
if (is_array ($value))
{
strip_slashes_recursive ($array[$key]);
}
else
{
$array[$key] = stripslashes($value);
}
}
}
完美的谢谢你的帮助,太好了!谢谢你的帮助。