Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strict standards error

Tags:

php

The function parse_users returns an array.

I am doing the following in another function:

return reset($this->parse_users($records));

But I get a Strict Standards: Only variables should be passed by reference in...

Is it because I do a reset() on the function?

Do I have to do it this way:

$users = $this->parse_users($records);
return reset($users);

Or is something else?

like image 564
PeeHaa Avatar asked Jul 17 '11 19:07

PeeHaa


People also ask

What is php strict standards?

Strict warnings are sent by PHP when certain old features are used or some code doesn't otherwise adhere to php's strict standards. In general, these errors are only helpful in development and can be ignored in production. In PHP 5.4, the E_STRICT error type was set to output by default.

How do I turn off strict mode in PHP?

Hi just to make it little ease, for those who are using wamp, you can disable errors by clicking php > php settings >> display errors. If it is checked then uncheck it.


2 Answers

That's it exactly. reset takes a reference to an array as a parameter, so it basically needs a real variable to reference -- even if it is a pass-by-reference value.

like image 50
cwallenpoole Avatar answered Oct 15 '22 07:10

cwallenpoole


why didn't you try your

$users = $this->parse_users($records);
return reset($users);

?

It's correct

like image 29
genesis Avatar answered Oct 15 '22 09:10

genesis