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.
Printable View
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.
I just tried this as per http://www.php.net/manual/en/function.ini-get.php :
...but it prints out string(0) "" unknownPHP 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';
}
?>
This is for another project, genius ;)Quote:
Hmm, also didn't know we chucked one in there, too :D :D
ah well :p
I just chucked it there ;)
This didn't help either...grr :mad:
It just prints out unknown.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';
}
?>
$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.Quote:
Originally posted by scoutt
$var = ini_get(register_globals);
if ($var == 0){
echo "register globals is Off";
}else{
echo "register globals is On";
}
Also tried this:
And it prints out:PHP Code:
$all = ini_get_all();
foreach($all['register_globals'] as $s)
{
echo ">$s<<br>";
}
><
><
>7<
:confused:
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.
:confused:Quote:
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.
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()
then look at the local value when it runs.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();
?>
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)?
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
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.
scoutt's snippet works fine for me as well.
see http://www.php.net/manual/en/function.ini-get.php for kicks and giggles
Okay, simplified:Quote:
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.
Your script: on
phpinfo: off
php.ini: off
So...eh...
Okay, now your script is working :confused: must have been a typo or something ;)
Cheers :)
lol, filburt, even I figured this one out on my own the other day :p