ID: 33591
Updated by: [EMAIL PROTECTED]
Reported By: nobody at somewhere dot de
-Status: No Feedback
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.3.11
New Comment:
line 1: $bug= & f();
line 2: $bug= f();
line 3: $bug[0]= "[i DIDN'T set ar!]";
on line 1 you're turning $bug to a reference to $ar.
on line 2 you're setting the value of the referenced variable.
on line 3 you're changing the value of $bug (which is still referencing
$ar, so $ar gets changed too).
Adding unset($bug) between 1-st & 2-nd lines resolves it, because in
this case unset() kills the reference.
No bug here.
Previous Comments:
------------------------------------------------------------------------
[2005-07-21 10:58:34] sl at yes-co dot nl
Output on PHP 5.1.0-dev (Jul 21 2005 08:29:50):
array(1) {
[0]=>
string(15) "[element of ar]"
}
array(1) {
[0]=>
string(15) "[element of ar]"
}
array(1) {
[0]=>
string(18) "[i DIDN'T set ar!]"
}
------------------------------------------------------------------------
[2005-07-14 01:00:04] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2005-07-06 16:57:11] [EMAIL PROTECTED]
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2005-07-06 16:48:50] nobody at somewhere dot de
Description:
------------
I don't know about any php-Interna
Somehow a PHP-Variable seems to have a Flag that means "Is a
Reference". This Flag is not resetted under the conditions I show in
the code below.
Cheers!
Reproduce code:
---------------
#---
global $ar;
$ar= array("[element of ar]");
var_dump($ar);
$ok= f();
$ok[0]= "[i DIDN'T set ar!]";
var_dump($ar);
$bug= & f();
$bug= f(); # bug! doesn't reset reference-flag
$bug[0]= "[i DIDN'T set ar!]";
var_dump($ar);
function & f() {
global $ar;
return $ar;
}
exit;
#---
Expected result:
----------------
array(1) { [0]=> string(15) "[element of ar]" }
array(1) { [0]=> string(15) "[element of ar]" }
array(1) { [0]=> string(15) "[element of ar]" }
Actual result:
--------------
array(1) { [0]=> string(15) "[element of ar]" }
array(1) { [0]=> string(15) "[element of ar]" }
array(1) { [0]=> string(18) "[i DIDN'T set ar!]" }
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33591&edit=1