【发布时间】:2018-04-27 23:01:53
【问题描述】:
我有这个错误:
警告:strlen() 期望参数 1 为字符串,数组在 /includes/functions/general.php 第 159 行给出
在文件中:
function tep_get_all_get_params($exclude_array = '') {
global $HTTP_GET_VARS;
if (!is_array($exclude_array)) $exclude_array = array();
$get_url = '';
if (is_array($HTTP_GET_VARS) && (sizeof($HTTP_GET_VARS) > 0)) {
reset($HTTP_GET_VARS);
while (list($key, $value) = each($HTTP_GET_VARS)) {
if ( (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) { // THIS IS 159 LINE
$get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';
}
}
}
return $get_url;
}
有人可以帮我解决这个问题吗?
【问题讨论】:
-
错误提示
$value是一个数组(“给定数组”),而它应该是一个字符串(“期望参数 1 是字符串”)。为什么会这样? -
为防止混淆,请考虑使用
count而不是sizeof, it other programming languagessizeof` 意味着完全不同的东西。 -
对于这样的代码,设置和具有调试功能的 IDE 通常是有利的,然后通过任何调用和迭代来了解正在发生的事情。 -- 看起来它也是为古老的 PHP4 版本编写的,可能需要彻底检修。
-
那么你能写信给我吗,我应该在代码中更改什么以避免错误?我是可怜的php..
-
停止使用
$HTTP_GET_VARS它已被弃用。 php.net/manual/en/reserved.variables.get.php
标签: php string parameters warnings strlen