|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-07-05 08:55 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 22:00:01 2025 UTC |
Description: ------------ When passing in variable which gets assigned in function call, PHP wrongly thinks it got something other than variable: function test(&$a) { $a = 2; } // take $a as reference test($m = 5); // should mean assign 5 to $m and _then_ pass in variable $m Instead it looks like php sends scalar 5 to function (and throws E_STRICT error), which is plainly wrong. Or is the documentation wrong about operator precedence? Really: <?php $m=1;test($m); ?> should mean exactly same as <?php <?php test($m=1); ?>. Currently it does not and IMHO this is very counter-productive to PHP's KISS principle. Especially that last S. By the way I know there are tons of similar bug reports marked Bogus. But please think about this report once more. Also you should consider the fact that the 'expected result' shown in this bug report is not hand-written but obtained from PHP 4.4.2 - and this only means serious BC problem. Reproduce code: --------------- <?php function test(&$a) { $a = 2; } $m = 1; test($m); var_dump($m); test($m = 1); var_dump($m); ?> Expected result: ---------------- int(2) int(2) Actual result: -------------- int(2) int(1)