#31956 [Csd->Bgs]: array passed by reference is modified but should'nt be
| From: | johannes@php.net | Date: | Mon, 14 Feb 2005 07:17:51 +0000 |
| Subject: | #31956 [Csd->Bgs]: array passed by reference is modified but should'nt be | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-74013@lists.php.net to get a copy of this message | ||
ID: 31956
Updated by: johannes@php.net
Reported By: pillepop2003 at yahoo dot de
-Status: Closed
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 4CVS, 5CVS (2005-02-13)
Previous Comments:
------------------------------------------------------------------------
[2005-02-14 08:13:41] pillepop2003 at yahoo dot de
okay, you seem to be right.
in my test unset() did not work correctly (for whatever reason...) in
the beginning, what made it hard to believe that a variable is set to
NULL and can't be unset.
sorry for wasting your time.
Keep up thw good work.
------------------------------------------------------------------------
[2005-02-13 22:49:18] sniper@php.net
Don't mix my example with yours, mine is passing something else than an
array index to the function. And this is actually (kind of) documented
as undefined:
http://www.php.net/manual/en/language.references.pass.php
See the last paragraph, about what can be passed by reference:
"Any other expression should not be passed by reference, as the result
is undefined."
------------------------------------------------------------------------
[2005-02-13 20:29:19] pillepop2003 at yahoo dot de
<?php
function func1(&$a)
{
// void();
}
var_dump($c);
func1($c);
var_dump($c);
?>
should IMO output
array(2) {
["one"]=>
int(1)
}
array(2) {
["one"]=>
int(1)
}
Why should the non-existing variable get a value (of NULL) - this is a
paradoxon, isn't it? Can't it just be "not mentioned"?
------------------------------------------------------------------------
[2005-02-13 18:14:24] sniper@php.net
What would you expect this to output:
<?php
function func1(&$a)
{
// void();
}
var_dump($c);
func1($c);
var_dump($c);
?>
IMO, this is exactly what you'd expect. The non-existing variable (or
in your example, non-existing array index) gets
value of NULL. I don't see what else should happen..
------------------------------------------------------------------------
[2005-02-13 17:57:31] sniper@php.net
This happens with both PHP_4_3 and HEAD from today.
(only verified that it happens. I don't know if it's intentional or not
:)
------------------------------------------------------------------------
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
http://bugs.php.net/31956
--
Edit this bug report at http://bugs.php.net/?id=31956&edit=1