Date: 11/27/00
- Next message: lenar <email protected>: "[PHP-DEV] PHP 4.0 Bug #7997: segmenation fault"
- Previous message: Ignacio Vazquez-Abrams: "Re: [PHP-DEV] Re: [PHP] ++ BUG?? (fwd)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ID: 7983
Updated by: joey
Reported By: arunas <email protected>
Status: Open
Bug Type: Unknown/Other Function
Assigned To:
Comments:
Well, part of this behavior is really not all that mysterious.
global $Piano;
This create a local variable $Piano, and makes it a reference
to $GLOBALS["Piano"]. Unsetting $Piano does nothing more than
break that reference, as is documented in the incompatibilities
list (http://www.php.net/version4/incompatibilities.php)
Previous Comments:
---------------------------------------------------------------------------
[2000-11-26 21:12:46] arunas <email protected>
I don't always know how variable arrives in a script. To be general, I have a function ClearVar($Name) that accepts the name of a variable, and goes through all of the global arrays to clear it.
This appears to work properly with HTTP_GET_VARS and HTTP_POST_VARS, but the GLOBALS array is a funny fish.
In fact, playing around to try to figure it out, I tried:
$Piano = "Hemmingway";
print "Before: Piano = $Piano<br>n";
unset($GLOBALS["Piano"]);
print "After: Piano = $Piano<br>n";
Which outputs:
Before: Piano = Hemmingway
After: Piano = ô®0Èõÿ¿
or some variant of that.
More surprisingly, if I use unset on an element of the GLOBALS array within a function even odder things happen. The following code:
$Piano = "Hemmingway";
print "Before: Piano = $Piano<br>n";
ClearTest();
print "After: Piano = $Piano<br>n";
$Piano = "Brahmbach";
print "Before: Piano = $Piano<br>n";
ClearTest();
print "After: Piano = $Piano<br>n";
function ClearTest()
{
global $Piano;
print "Before[ClearTest]: Piano = $Piano<br>n";
MyClearVar("Piano");
print "After[ClearTest]: Piano = $Piano<br>n";
}
function MyClearVar($Name)
{
unset($GLOBALS[$Name]);
}
Produces the following:
Before: Piano = Hemmingway
Before[ClearTest]: Piano = Hemmingway
After[ClearTest]: Piano = Hemmingway
After: Piano = |6(
Before: Piano = Brahmbach
Before[ClearTest]: Piano =
After[ClearTest]: Piano =
After: Piano = Brahmbach
So apparently not all is simple with $GLOBALS. There maybe something I'm missing, I may be abusing a convenience method, but boy are the results strange.
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=7983
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: lenar <email protected>: "[PHP-DEV] PHP 4.0 Bug #7997: segmenation fault"
- Previous message: Ignacio Vazquez-Abrams: "Re: [PHP-DEV] Re: [PHP] ++ BUG?? (fwd)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

