PDA

View Full Version : register_globals not work


wkkor
04-03-2007, 11:14 PM
I had been configured register_globals On, but it just seem like not work. I had use phpinfo() to display the php information and it show register_globals as On as well. Just feel weird why it just not work. Someone can please help me? I appreciate any help.

wkkor
04-03-2007, 11:15 PM
Additional, I had print_r($GLOBALS); and the variable is exist. eg: $GLOBALS['var'] is '123', but it is empty when I try to echo $var.

darksidepuffin
04-04-2007, 12:12 AM
In what context are you attempting to use the variable?register_globals only imports superglobal variables, it does not remove the need to use $GLOBALS["var"] or global $var inside of the function scope.

wkkor
04-04-2007, 12:54 AM
Thanks for your reply.
I attempt to use $_GET['var'] and global $var both. Or what should I do to enable this?

darksidepuffin
04-04-2007, 01:27 AM
Actually, your right. register_globals should, in fact, allow this.

assuming the url is being used as file.php?var=blah


echo $_GET["var"];


and:


echo $var;


should have the same functionality. Please post or pm me a link to a file with phpinfo in it, as well as post the code your attempting to work with.

wkkor
04-04-2007, 02:23 AM
actually I am customize Joomla CMS. While it go to a component, I can attempt to the variable but it is fine when i create a page to testing.
phpinfo: http://p0701.activehack.com/myinfo.php
test: http://p0701.activehack.com/debug.php?var=123

darksidepuffin
04-04-2007, 02:29 AM
You should be looking for variable name conflicts. Change the name to something absolutely outlandish like cheese001potatosteak and then see if it still has a problem.

wkkor
04-04-2007, 02:41 AM
I had added:
$thisisthetestingvariablewhichfordebug = 'aaa';
However, it still fail to echo $thisisthetestingvariablewhichfordebug.
Once i added following at top, it can get the correct result:
global $thisisthetestingvariablewhichfordebug;

darksidepuffin
04-04-2007, 02:47 AM
Then that means that your original variable name was conflicting, and the code your writing is being used in a scope other than the global scope [eg: a function or a php object], thus using $GLOBALS["var"], assuming "var" isn't the name of a conflicting variable, should resolve your issue as well.

wkkor
04-04-2007, 03:22 AM
Hm... I think what the reason.... Can I confirm with you whether the register_globals will allow us to attempt in the class function with the same way?

darksidepuffin
04-04-2007, 03:26 AM
Within a class, as with a function, you will need to use global or $GLOBALS, but yes, you can test it the same way -- use a var_dump in the member function of the class. In the case of classes, I suggest you use $GLOBALS.

erisco
04-04-2007, 10:26 AM
Hello?!? register_globals? Am I on the same page here? DO NOT ENABLE THIS!

Elaboration can come later... busy

darksidepuffin
04-04-2007, 11:46 AM
Hello?!? register_globals? Am I on the same page here? DO NOT ENABLE THIS!


The question wasn't rather or not to enable register_globals, the question was how to deal with the issue they were having with it. I agree that register_globals is better left disabled, but that wasn't the question. Therefore, I chose not to hijack the thread with an anti-register_globals rant, and I suggest you make the same choice.


fyi, wkkor -- if your curious as to the appropriate method for not using register_globals, you may, at your discretion, read this (http://www.htmlforums.com/showpost.php?p=349797&postcount=5).

¥åßßå
04-04-2007, 12:42 PM
The question wasn't rather or not to enable register_globals, the question was how to deal with the issue they were having with it. I agree that register_globals is better left disabled, but that wasn't the question. Therefore, I chose not to hijack the thread with an anti-register_globals rant, and I suggest you make the same choice.


fyi, wkkor -- if your curious as to the appropriate method for not using register_globals, you may, at your discretion, read this (http://www.htmlforums.com/showpost.php?p=349797&postcount=5).

Yeah but he's right ;)

Mind you :
The question wasn't rather or not to enable register_globals, the question was how to deal with the issue they were having with it. I agree that register_globals is better left disabled, but that wasn't the question. Therefore, I chose not to hijack the thread with an anti-register_globals rant, and I suggest you make the same choice.


fyi, wkkor -- if your curious as to the appropriate method for not using register_globals, you may, at your discretion, read this (http://www.htmlforums.com/showpost.php?p=349797&postcount=5).
So are you ;)

Aside from the "turn register_globals off" debate, if you're coding for more than just your own server then you should assume, and code for, them being turned off. In the long run (apart from making your code infinately more secure) it'll make your code more robust ( ie/ it'll still work on a server whether register_globals is turned on or off). It's similar to getting into the habit of coding using "<?php" even if your server supports short tags.

¥