#38626 [NEW]: Passing not variables by Reference
| From: | php at swapo dot de | Date: | Mon, 28 Aug 2006 12:43:48 +0000 |
| Subject: | #38626 [NEW]: Passing not variables by Reference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-101434@lists.php.net to get a copy of this message | ||
From: php at swapo dot de
Operating system: all
PHP version: 5.1.5
PHP Bug Type: Feature/Change Request
Bug description: Passing not variables by Reference
Description:
------------
The behaviour of pass by reference is a little odd.
As stated here (http://www.php.net/manual/en/language.references.pass.php)
passing by reference works only if you use a variable as a function
argument.
This is also the case with builtin functions like array_pop but I can
think of many situations when it makes sense to use a function's return
value as an argument to another function.
A common example (perhaps not the best though) is to get a file extension
by combining explode and array_pop.
This wasn't a problem until PHP 5.1 and I think it shouldn't be now.
Reproduce code:
---------------
// doesn't work
$extension = array_pop(explode('.', $filename));
// works
$parts = explode('.', $filename);
$extension = array_pop($parts);
unset($parts);
// surpressing the error message works too
$extension = @array_pop(explode('.', $filename));
Expected result:
----------------
All examples should give the same result.
Actual result:
--------------
The first example results in an error message as the argument for
array_pop must be a variable:
Strict Standards: Only variables should be passed by reference
--
Edit bug report at http://bugs.php.net/?id=38626&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38626&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38626&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38626&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38626&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=38626&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38626&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38626&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38626&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38626&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38626&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=38626&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=38626&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38626&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38626&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38626&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38626&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38626&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38626&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38626&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38626&r=mysqlcfg