今天早上当我点击广告后时,我在我的网站上收到了此错误
我试过查看代码,但似乎没有发现任何问题
if (!function_exists('adforest_extarct_link')) {
function adforest_extarct_link($string) {
$arr = explode('|', $string);
list($url, $title, $target, $rel) = $arr; /* This is line 148 */
$rel = urldecode(adforest_themeGetExplode($rel, ':', '1'));
$url = urldecode(adforest_themeGetExplode($url, ':', '1'));
$title = urldecode(adforest_themeGetExplode($title, ':', '1'));
$target = urldecode(adforest_themeGetExplode($target, ':', '1'));
return array("url" => $url, "title" => $title, "target" => $target, "rel" => $rel);
}
这是错误消息
未定义的偏移量:3 in/customers/7/6/1/corpersmarket.com/httpd.www/wp-content/themes/adforest/inc/theme_shortcodes/short_codes_functions.php 在第 148 行
它实际上有 3 行错误:
Notice: Undefined offset: 1 in /customers/7/6/1/corpersmarket.com/httpd.www/wp-content/themes/adforest/inc/theme_shortcodes/short_codes_functions.php on line 148
Notice: Undefined offset: 2 in /customers/7/6/1/corpersmarket.com/httpd.www/wp-content/themes/adforest/inc/theme_shortcodes/short_codes_functions.php on line 148
Notice: Undefined offset: 3 in /customers/7/6/1/corpersmarket.com/httpd.www/wp-content/themes/adforest/inc/theme_shortcodes/short_codes_functions.php on line 148
问题大致是 list (( 中 PHP 未定义偏移量的副本
然而
您的list
期望至少 4 个 prameter - 但您的 $arr
数组只有 1。所以以下三个是空的。(请记住,数组从 0 开始(。因此,您的$string
不包含explode
函数按预期工作的|
字符。
解决方法:
源语言:
$arr = explode('|', $string);
list($url, $title, $target, $rel) = $arr; /* This is line 148 */
成为:
$arr = array_pad(explode('|', $string), 4, null);
list($url, $title, $target, $rel) = $arr;
这是做什么的:
将数组填充为至少包含 4 个值;以便始终填充list
值,即使它们可能仍为空。