Re: Globals question

From: Date: Fri, 02 May 2003 18:09:43 +0000
Subject: Re: Globals question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146167@lists.php.net to get a copy of this message
The default for register globals is off, so you should write all new code to work without register globals. Since the super globals $_GET, $_POST and $_REQUEST have been available since PHP 4.1 I would recommend using them or using the $HTTP_POST and $HTTP_GET variables (which are not super globals but are available in PHP prior to version 4.1). You will find that if you insist on register globals on your application will be broken by default on most new installs. Jason Ryan A wrote:
Hi, (Warning, kind of newbie alert) I have created a script which will take a lot of values from a form I am getting various values entered into the script from variables like $customer_name, $product_id etc etc I just take and use those variables as is eg: I _DONT_ do: $customer_name== $_GET['page']; BUT my friend tells me that I should do that as "register globals" are off on a lot of servers....which is getting me quite confused. Should I convert all my scripts so it will work with register globals off? Then for "GET" I use $_GET and for "POST" I am guessing I will have to use $_POST, or should I use $_REQUEST? or (my favourite alternative) is just keep the code as is and if they dont have register globals on...tough luck! :-) What do you think? Because just thinking of going through all those damn variables one by one and converting them sure sounds like a pain in the....exactly what you thought :-) After going on google and searching for the answer I see that even the creator or PHP thinks that register globals should be on as putting it off does not add to a higher sense of security.(http://www.webmasterbase.com/article/767/) Any advise/suggestions/comments welcome. Cheers, -Ryan


« previous php.general (#146167) next »