When register_globals is on

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lostinfog
Forum Newbie
Posts: 8
Joined: Wed Apr 26, 2006 4:22 am

When register_globals is on

Post by lostinfog »

i've finished some codes. Those codes works well when register_globals is off. I know this setting is default since PHP v4.2.
Buf when register_globals is on, error occured.
I'd like to know whether or not it's possible to tell a variable is from session or get? If possible, how?
TIA!
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

By only retrieving variables from superglobal arrays.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

unless you have weird code, I don't know how code would break when it works without register_globals on..
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: When register_globals is on

Post by RobertGonzalez »

lostinfog wrote:i've finished some codes. Those codes works well when register_globals is off. I know this setting is default since PHP v4.2.
Buf when register_globals is on, error occured.
I'd like to know whether or not it's possible to tell a variable is from session or get? If possible, how?
TIA!
First tip, leave register globals off.

As far as telling where a variable comes from, dont't know if you can do that except for running an isset if check against all GPCS vars, but then there is an issue of precedence in these vars so the results might be skewed. But I would seriously recommend leaving register globals off.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ini_get('variables_order') will help determine it..

http://php.net/ini.core#ini.variables-order
Post Reply