#35995 [Opn]: Problems defining vars in arguments
| From: | jadelucca at comcast dot net | Date: | Fri, 13 Jan 2006 11:55:45 +0000 |
| Subject: | #35995 [Opn]: Problems defining vars in arguments | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-91841@lists.php.net to get a copy of this message | ||
ID: 35995
User updated by: jadelucca at comcast dot net
Reported By: jadelucca at comcast dot net
Status: Open
Bug Type: Scripting Engine problem
Operating System: Windows XP
PHP Version: 5.1.2
New Comment:
Under reproduce code, that SAME EXACT CODE WORKS on PHP 5.1.1! I just
testing.
The SECOND (Modification code) sends a parse error there too, so maybe
the 2nd example can't be done.
But the bug still lies within PHP 5.1.2! (For those who speed-read
through this and perhaps misundestood me.)
Previous Comments:
------------------------------------------------------------------------
[2006-01-13 12:49:04] jadelucca at comcast dot net
Description:
------------
You cannot define a variable in arguments in 5.1.2, but you could in
previous versions.
Reproduce code:
---------------
AN EXAMPLE would be:
<?php
function prefix(&$text) {
$text = "Prefix " . $text;
}
prefix($text = "Add prefix to this here, which would do that in older
versions but not this one.");
?>
Expected result:
----------------
After I run the code above, $text *should* be "Prefix Add prefix..."
etc. This is how it worked in older versions of PHP.
Actual result:
--------------
$text is unmodified. It passes-by-value, not reference, despite the
fact that I added the & in the argument list.
*Modification example*
If I swap the & sign from the function argument list to the actual
function arguments, like so:
<?php
function prefix($text) {
$text = "Prefix " . $text;
}
prefix(&$text = "Add prefix to this here, which would do that in older
versions but not this one.");
?>
I get Parse error: syntax error, unexpected '=', expecting ')'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35995&edit=1