使用if / else短码的php未定义索引错误

时间:2012-05-04 02:35:39

标签: undefined-index

我正在尝试清理错误日志。仍然会生成此错误:

[Tue Apr 24 06:09:32 2012] [error] [client 44.444.69.28] PHP Notice:  Undefined index:  current_id in /srv/www/virtual/website.com/htdocs/wp-content/themes/mimbo/sidebar.php on line 12

来自此代码:

$posts = get_posts('numberposts=4&exclude=' . isset($GLOBALS['current_id']) ? $GLOBALS['current_id'] : '' . '&category='. $category->term_id);

我也试过这个:

$posts = get_posts('numberposts=4&exclude=' . array_key_exists('current_id',$GLOBALS) ? $GLOBALS['current_id'] : '' . '&category='. $category->term_id);

我添加了if / else短码来检查我认为可以消除错误的当前id,但它仍然没有消失。

0 个答案:

没有答案