【问题标题】:PHP Strict Standards: Only variables should be passed by reference // array_pop [duplicate]PHP 严格标准:只能通过引用传递变量 // array_pop [重复]
【发布时间】:2016-06-04 08:24:15
【问题描述】:

因为我使用的是 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    }

请问,我该如何解决? :)

谢谢!

【问题讨论】:

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


    【解决方案1】:

    只需替换

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

    与

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

    出现警告是因为 array_pop 期望参数是 reference,而函数返回值不是。

    【讨论】:

    • 你摇滚!非常感谢^^
    猜你喜欢
    • 2013-05-21
    • 1970-01-01
    • 2012-04-08
    • 2015-02-02
    • 2017-07-24
    • 1970-01-01
    • 2014-11-01
    相关资源
    最近更新 更多