Req #63862 [Opn->Nab]: Passing by reference: func($a = $b);
| From: | datibbaw@php.net | Date: | Wed, 09 Oct 2013 07:29:17 +0000 |
| Subject: | Req #63862 [Opn->Nab]: Passing by reference: func($a = $b); | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10460@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63862&edit=1
ID: 63862
Updated by: datibbaw@php.net
Reported by: bobwei9 at hotmail dot com
Summary: Passing by reference: func($a = $b);
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: Documentation problem
Operating System: Mac OS X Mountain Lion
PHP Version: master-Git-2012-12-27 (Git)
Block user comment: N
Private report: N
New Comment:
.
Previous Comments:
------------------------------------------------------------------------
[2013-10-09 07:26:48] datibbaw@php.net
This behaviour is documented under the References section:
http://www.php.net/manual/en/language.references.pass.php
This is not going to change.
------------------------------------------------------------------------
[2013-10-09 07:20:24] krakjoe@php.net
This is expected behaviour, you cannot use an expression as a reference, you must assign the result
of the expression to a variable and pass it by reference.
------------------------------------------------------------------------
[2013-01-05 10:35:17] bobwei9 at hotmail dot com
Yeah, it is primarily not documented, but is there a reason why not to change
behavior? I don't think that it'll introduce a BC break, because it makes today
no sense to write such a code. (Throws E_STRICT error)
I mean: if there is a $variable = on the beginning of an argument and the
argument expects a reference, then evaluate first the part after the first =,
assign the result to the $variable and pas this variable by reference.
Or requires this minor change to be a rfc...?
------------------------------------------------------------------------
[2013-01-05 05:09:45] laruence@php.net
$a = $b result a tmp value, not the left variable self.
I wrote a simple explaination for this before, (however it's in chinese)
http://www.laruence.com/2010/01/03/1225.html
change to doc problem instead
------------------------------------------------------------------------
[2012-12-31 22:52:06] bobwei9 at hotmail dot com
I know how it works now, but I don't know if it is intended (It isn't documented.)
Then I wish that the first variable $a = $b = $c; is passed by array.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=63862
--
Edit this bug report at https://bugs.php.net/bug.php?id=63862&edit=1