PHP 严格标准:只有变量应该通过引用传递 // array_pop

PHP Strict Standards: Only variables should be passed by reference // array_pop

因为我在 PHP 5.6,所以我有这个警告(不在 PHP 5.2):

PHP Strict Standards:  Only variables should be passed by reference in blockcategories_top.php on line 157

这是第 157 行:

line 155    if ($cookie->last_visited_category) {
line 156      $c = new Category(intval($cookie->last_visited_category));
line 157      $oldies = array_pop($c->getParentsCategories());
line 158      $oldies = $oldies['id_category'];
line 159      $smarty->assign('oldies', $oldies);
line 160    }

拜托,我该如何解决? :)

谢谢!

只需更换

$oldies = array_pop($c->getParentsCategories());

$oldies = $c->getParentsCategories();
$oldies = array_pop($oldies);

出现警告是因为 array_pop expects the parameter to be a reference,而函数 return 值不是。