|
-
Jun 11th, 2002, 09:26 AM
#1
Thread Starter
Member
register_globals
How can I find out if it is on or off? I'm guessing there are at least two variables that tell you, like $_SERVER['REGISTER_GLOBALS'] and $register_globals, to account for the very nature of the question.
-
Jun 11th, 2002, 09:39 AM
#2
PowerPoster
-
Jun 11th, 2002, 09:40 AM
#3
Thread Starter
Member
I just tried this as per http://www.php.net/manual/en/function.ini-get.php :
PHP Code:
register_globals is
<?
$val = ini_get('register_globals');
var_dump($val);
if ($val == "string(0) \"\"")
{
echo 'off';
}
elseif($val == "string(1) \"1\"")
{
echo 'on';
}
else
{
echo 'unknown';
}
?>
...but it prints out string(0) "" unknown
-
Jun 11th, 2002, 09:40 AM
#4
Thread Starter
Member
This is for another project, genius
-
Jun 11th, 2002, 09:40 AM
#5
Thread Starter
Member
Hmm, also didn't know we chucked one in there, too
-
Jun 11th, 2002, 09:42 AM
#6
PowerPoster
ah well 
I just chucked it there
-
Jun 11th, 2002, 09:51 AM
#7
Thread Starter
Member
This didn't help either...grr 
PHP Code:
register_globals is
<?
function svar_dump($data)
{
ob_start();
var_dump($data);
$ret_val = ob_get_contents();
ob_end_clean();
return $ret_val;
}
$val = ini_get('register_globals');
svar_dump($val);
if ($val == "string(0) \"\"")
{
echo 'off';
}
elseif($val == "string(1) \"1\"")
{
echo 'on';
}
else
{
echo 'unknown';
}
?>
It just prints out unknown.
-
Jun 11th, 2002, 09:55 AM
#8
$var = ini_get(register_globals);
if ($var == 0){
echo "register globals is Off";
}else{
echo "register globals is On";
}
-
Jun 11th, 2002, 09:59 AM
#9
Thread Starter
Member
Originally posted by scoutt
$var = ini_get(register_globals);
if ($var == 0){
echo "register globals is Off";
}else{
echo "register globals is On";
}
Doesn't work...it prints out Off when they're really on.
Also tried this:
PHP Code:
$all = ini_get_all();
foreach($all['register_globals'] as $s)
{
echo ">$s<<br>";
}
And it prints out:
><
><
>7<
-
Jun 11th, 2002, 10:04 AM
#10
sorry that works. don't know what you are doing. there are 2 settings for register globals. the master and the local. you can't control the master. if it is off you can't turn it on. but you can control the local, that is what that code does is check the local value. so look again because it works on mine.
-
Jun 11th, 2002, 10:06 AM
#11
Thread Starter
Member
Originally posted by scoutt
sorry that works. don't know what you are doing. there are 2 settings for register globals. the master and the local. you can't control the master. if it is off you can't turn it on. but you can control the local, that is what that code does is check the local value. so look again because it works on mine.

What I'm saying is that register_globals is set to on in php.ini, but this prints out off, which is not what I want. I tried it as 'register_globals' and register_globals and both did the same thing.
-
Jun 11th, 2002, 10:09 AM
#12
that is the master level you set to on. run phpinfo() and see what it is set at. if you want to really check it use this script. this will let you turn it on and off by changing the value in the ini_set()
PHP Code:
<?
//echo get_cfg_var (register_globals);
$var = ini_get(register_globals);
if ($var == 0){
echo "register globals is Off";
}else{
echo "register globals is On";
}
// Turns the register_globals on
ini_set("register_globals", 0); // change to 1 for on
$var2 = ini_get(register_globals);
if ($var2 == 0){
echo "register globals is Off";
}else{
echo "register globals is On";
}
phpinfo();
?>
then look at the local value when it runs.
-
Jun 11th, 2002, 10:34 AM
#13
Thread Starter
Member
Maybe I'm just not getting something...but I want to see what the value of register_globals in php.ini is set to. In phpinfo() it is shown to be off, as it is set in php.ini. I don't want to set the value to on or off, I just want to find out what it is.
Are you saying that I can change the value of register_globals for the current script (which I don't want to do)?
-
Jun 11th, 2002, 10:40 AM
#14
Fanatic Member
yes. you can turn it off or on. The begining part of scoutts script reads what the value is of register_globals, the second part will either turn it on or off depending on your preference.
-Matt
-
Jun 11th, 2002, 10:45 AM
#15
Arien, I know you don't want to turn it off or on, that was to jsut show you what happens when you turn it off and on and that it works. now you said a couple posts up that my script said ti was off when it was on in the ini file. then yoiu said phpinfo said it was off and it is off in the ini. So you are getting me confused here. my scripts works so what ever it says it what the variable is.
-
Jun 11th, 2002, 11:14 AM
#16
Stuck in the 80s
scoutt's snippet works fine for me as well.
-
Jun 11th, 2002, 11:21 AM
#17
PowerPoster
-
Jun 11th, 2002, 11:36 AM
#18
Thread Starter
Member
Originally posted by scoutt
Arien, I know you don't want to turn it off or on, that was to jsut show you what happens when you turn it off and on and that it works. now you said a couple posts up that my script said ti was off when it was on in the ini file. then yoiu said phpinfo said it was off and it is off in the ini. So you are getting me confused here. my scripts works so what ever it says it what the variable is.
Okay, simplified:
Your script: on
phpinfo: off
php.ini: off
So...eh...
-
Jun 11th, 2002, 11:39 AM
#19
Thread Starter
Member
-
Jun 11th, 2002, 10:58 PM
#20
Fanatic Member
lol, filburt, even I figured this one out on my own the other day
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|