Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Since i'm in PHP 5.6, i have this warning (not in PHP 5.2) :

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

Here is the line 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    }

Please, how can i fix it ? :)

Thanks !

like image 381
Shark34 Avatar asked Feb 05 '26 12:02

Shark34


1 Answers

Just replace

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

with

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

The warning happens because array_pop expects the parameter to be a reference, and function return values are not.

like image 177
Matteo Tassinari Avatar answered Feb 07 '26 00:02

Matteo Tassinari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!