note 45962 deleted from ini.sect.data-handling by aidan
| From: | aidan@php.net | Date: | Thu, 25 Nov 2004 02:03:45 +0000 |
| Subject: | note 45962 deleted from ini.sect.data-handling by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80994@lists.php.net to get a copy of this message | ||
Note Submitter: mina86 at tlen dot pl
----
There's easier way of unregistering globals:
<?php
// Put that at the very begining fo the file
if (ini_get(register_globals)) {
foreach ($GLOBALS as $name => $value) {
if ($name{0}!=='_' || $name=='GLOBALS') {
unset($GLOBALS[$name]);
}
}
}
?>
The disagventage is that global variables starting with '_' won't be unset (just
don't use varaibles starting with '_' ;) use them only in classes). Also
$HTTP_GET_VARS, $HTTP_POST_VARS, etc will be unset but you can (and should) use $_GET, $_POST etc
instead.