Re: register_globals off or on, why on
| From: | Richard Lynch | Date: | Mon, 26 Aug 2002 22:48:38 +0000 |
| Subject: | Re: register_globals off or on, why on | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-114189@lists.php.net to get a copy of this message | ||
>> "Geeklog needs the register_globals variable turned on in order to work.
>> Since PHP 4.2.0, the default for register_globals is "off". To fix it,
>> simply add the following line to your php.ini file
>
>Is this not *wrong*. It sounds to me like fake laziness. Nothing drives
>me bonkers more than trying to track down a variable that is inherited
>from who knows where.
>
>Perhaps I'm missing something. I've recently worked on a lot of PHP
>code written by others and it's a nightmare trying to track down where
>a variable is defined and where it's value might be changed. Perhaps
>there is some tool I can use to trace this. I dunno.
>
>Am I correct in my aversion to globals or I am I missing their true
>value and perhaps some tools I could use when working on apps that have
>more than 50 php files floating all over the place and no
>documentation.
If it's not obvious where the value is coming from, whether they have
register_globals "on" or "off" isn't really going to help.
If the code is that messy, then they'll probably have something like:
<?php
$i = $_REQUEST['i'];
?>
in one file, and then start using $i out of the blue 37 files later, and 'i'
is *such* a great variable name, isn't it?
register_globals "off" only stops the over-riding of un-initialized
variables from the "outside" world (GET/POST/COOKIE).
If you've got crappy code with un-initialized variables in the first place,
you've got much bigger problems than register_globals -- You need to throw
out a big pile of code.
Unfortunately, some very popular but crappy code-bases out there continue to
be used by the masses, so we're all stuck with stupid register_globals
settings because of poor programming.
It's the right solution for a [bleeped]-up world, but that doesn't make one
not wish for a better world.
I guess I'm saying that there is only one correct tool to use for
applications with 50 php files floating all over the place and no
documentation:
rm -rf application
YMMV NAIAA IANAL
--
Like Music? http://l-i-e.com/artists.htm