ID:               38013
 Updated by:       [EMAIL PROTECTED]
 Reported By:      flex at city dot ee
-Status:           Open
+Status:           Bogus
 Bug Type:         Variables related
 Operating System: Linux
 PHP Version:      5.1.4
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

$m = 5 is an expression, not a variable.


Previous Comments:
------------------------------------------------------------------------

[2006-07-05 08:33:51] flex at city dot ee

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)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38013&edit=1

Reply via email to