|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-05-02 08:03 UTC] eth at ethaniel dot com
Description:
------------
I get a "PHP Strict Standards: Only variables should be passed by reference in"
error where there should be none.
Test script:
---------------
echo array_pop(array_keys(array("erwre")));
Expected result:
----------------
Result: 0.
Actual result:
--------------
The script returns the result (0), but also a "PHP Strict Standards: Only
variables should be passed by reference in" in my error log.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 22:00:01 2025 UTC |
I have a different example than the one given. Consider: function myfunc( &$refvar ) { ... } $horse = myfunc( $value = array() ); The code example above also gets the same exception, however, this does not seem correct. This suggests that the type of "$value = array()" is expression and not a variable. But this violates an assumption in the language. Is this assumption incorrect? Should it be incorrect? As in the original reported form of the problem, I believe there should be some forgiveness in the call-by-reference receiver. I can understand why NOT to do that, but there are safe ways to do it anyway, like create a new zval for local use. But it's more important to me that $value = array() evaluates to the VARIABLE $value and NOT an expression. What expression could it possibly represent? The supposed expression in such a case is meaningless, whereas the variable is meaningful and useful. Any chance this could be fixed in future?