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

Sha*_*k34 0 php standards strict php-5.2 php-5.6

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

PHP Strict Standards:  Only variables should be passed by reference in blockcategories_top.php on line 157
Run Code Online (Sandbox Code Playgroud)

这是第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    }
Run Code Online (Sandbox Code Playgroud)

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

谢谢 !

Mat*_*ari 7

只需更换

$oldies = array_pop($c->getParentsCategories());
Run Code Online (Sandbox Code Playgroud)

$oldies = $c->getParentsCategories();
$oldies = array_pop($oldies);
Run Code Online (Sandbox Code Playgroud)

发生警告是因为array_pop期望参数是引用,而函数返回值不是.