Reputation: 1
I want to be able to flush all variables in the global scope using a single function with one call to unset(). I want to keep all the variables that exist in _GET, _POST, _REQUEST, _COOKIE, _SERVER, _ENV, _FILES, _SESSION, and remove only the variables that exist in $GLOBALS[variable]. So say my $GLOBALS contained...
<php>
Array
(
[GLOBALS] => Array
*RECURSION*
[_POST] => Array
(
)
[var_3] => Array
(
)
[_GET] => Array
(
)
[_COOKIE] => Array
(
)
[_SERVER] => Array
(
[HTTPS] => on
[APPL_MD_PATH] => /docs/
[APPL_PHYSICAL_PATH] => /www/docs/
[INSTANCE_ID] => 1
[INSTANCE_META_PATH] => /
[LOGON_USER] =>
[REQUEST_URI] => /test.php
[URL] => /test.php
[SCRIPT_FILENAME] => /www/docs/test.php
[DOCUMENT_ROOT] => /www/docs/
[PHP_SELF] => /test.php
[HTTP_HOST] => localhost
)
[_ENV] => Array
(
)
[_FILES] => Array
(
)
[_REQUEST] => Array
(
)
[var_2] => Array
(
)
[var_3] => Array
(
)
)
</php>
I would want to flush var_1, var_2 and var_3.
Upvotes: 0
Views: 1172
Reputation: 14649
You can edit your php.ini
file and set:
variables_order = ""
...Setting to "" means no superglobals will be set. [0]
[0] http://php.net/manual/en/ini.core.php#ini.variables-order
Upvotes: 5