From: jadelucca at comcast dot net
Operating system: Windows XP
PHP version: 5.1.2
PHP Bug Type: Scripting Engine problem
Bug description: Problems defining vars in arguments
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 bug report at http://bugs.php.net/?id=35995&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=35995&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=35995&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=35995&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35995&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=35995&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35995&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35995&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35995&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35995&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35995&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=35995&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=35995&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35995&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35995&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35995&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35995&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35995&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35995&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35995&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35995&r=mysqlcfg