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

时间:2016-02-22 18:55:35

标签: php standards strict php-5.6 php-5.2

由于我在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    }

拜托,我该怎么办呢? :)

谢谢!

1 个答案:

答案 0 :(得分:6)

只需替换

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

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

发生警告是因为array_pop期望参数为reference,而函数返回值不是。{/ p>