Bug #78475 [Com]: Unsetting or assigning a value to $GLOBALS makes it stop working
Edit report at https://bugs.php.net/bug.php?id=78475&edit=1
ID: 78475
Comment by: gpluskji at gmail dot com
Reported by: ayg at aryeh dot name
Summary: Unsetting or assigning a value to $GLOBALS makes it
stop working
Status: Open
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.3.9
Block user comment: N
Private report: N
New Comment:
I Have Seen Best Article on Your Blog Very Informative and Knowledgeable. My Website is the same in
this category please add my website on your post. https://apsaraofindia.com/
http://delhiescortservice.online/
https://apsaraofindia.com/jaipur-girls-escorts-service.html
https://apsaraofindia.com/jodhpur-girls-escorts-service.html
https://apsaraofindia.com/hyderabad-girls-escorts-service.html
Previous Comments:
------------------------------------------------------------------------
[2019-08-29 18:14:51] ayg at aryeh dot name
Description:
------------
$GLOBALS contains a reference to a magical array that has all the globals in it. Unsetting or
assigning a value to it seems to forevermore lose the reference to this magical array, making
$GLOBALS a regular old variable that has no connection to defined globals (although it's still
a superglobal).
Unsetting or assigning to $GLOBALS probably should fail, just like $this does. I spent some time
today trying to debug a scenario where $GLOBALS['someVar'] did not equal $someVar after I
had written "global $someVar". It turned out to be because someone had unset $GLOBALS
somewhere (they were trying to clear all global variables and restore them to an earlier state).
This is really confusing and should be disallowed. Or at least produce a notice or something.
Test script:
---------------
$a = 1;
unset( $GLOBALS );
function f() {
global $a;
unset( $GLOBALS ); // $GLOBALS = []; is the same
var_dump( $a );
var_dump( isset( $GLOBALS['a' ) );
}
f();
Expected result:
----------------
Either:
int(1)
bool(true)
Or:
NULL
bool(false)
Actual result:
--------------
int(1)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78475&edit=1
Thread (4 messages)