RE: [PHP] What does register_globals do?
| From: | Matt Schroebel | Date: | Mon, 22 Jul 2002 20:18:44 +0000 |
| Subject: | RE: [PHP] What does register_globals do? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-108930@lists.php.net to get a copy of this message | ||
> From: Matt Babineau [mailto:matt@criticalcode.com]
> Sent: Monday, July 22, 2002 3:59 PM
> Subject: [PHP] What does register_globals do?
>
> I have never had a clear understanding about what this does,
> the php.ini
> has an explanation but being newer to PHP I don't understand it very
> well. Could someone prodive a human explanation about what
> register_globals does and why it is so important?
Register globals makes it *really* easy to code in php. It's what takes the uri or posted form
data, and turns them into global variables in your script.
So if a url looked like:
http://www.fakename.com/index.php?target=help
and with register-globals on, php will create a variable, $target, which has the value
'help' in it. It's very useful and friendly but, if you don't initialize your
variables then some non-so-nice person could initialize them for you by passing them on the
uri/post/cookie/etc so that your code no longer works as expected.
You're safe with it on if you always initialize variables, and set error_reporting to E_ALL
while testing so you catch any you might otherwise miss.
If you leave it off, you need to use the associative arrays $_POST, $_GET etc. The above example
would be $_GET['target'].