Bug #17794: Setting a reference and value on one line
| From: | greg at mtechsolutions dot ca | Date: | Mon, 17 Jun 2002 03:51:17 +0000 |
| Subject: | Bug #17794: Setting a reference and value on one line | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-10819@lists.php.net to get a copy of this message | ||
From: greg@mtechsolutions.ca
Operating system: should be independent
PHP version: 4.1.2
PHP Bug Type: Scripting Engine problem
Bug description: Setting a reference and value on one line
Since you can do:
$a = $b = 1;
It is only natural to assume you can also do:
$a = &$b = 1;
However, this returns a parse error. Should it not return a refernce to $b
?
Although this (simple) example seems stupid, the reason this is a problem
is when you involve arrays (and in my case, objects):
$a = &$b[] = new Object();
I want to add a new object into $b, but I just want it to go to a new
element number, without having to iterate through (which is currently the
only work-around I can think of).
At the same time, I need a reference to that object stored in another
variable. I can't make a temporary object, as it will be lost (only the
object in the $b array is stored permenantly) and it can't be a copy of
the object, it has to be the specific instance stored in $b.
If this has been fixed in ZE2, please disregard.
--
Edit bug report at http://bugs.php.net/?id=17794&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17794&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17794&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17794&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17794&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17794&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17794&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17794&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17794&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17794&r=globals