Check wether Globals are on/off

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
nike
Forum Newbie
Posts: 14
Joined: Mon Apr 29, 2002 1:38 pm

Check wether Globals are on/off

Post by nike »

Hi,
how can I check in PHP wether the globals are registered on or off?
A short code snippet would be nice ;-)

Bye

Nike
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

take a look at

Code: Select all

<?php
var_dump(ini_get('register_globals'));
?>
with different values for register_globals

Code: Select all

if (ini_get('register_globals'))
{
   //register_globals on
}
else
{
   //register_globals off
}
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Further to Volka's answer and relating to finding out even more information about how PHP is setup...

If you want to find out information like this on your own installation of PHP do a search in your files and have a look at your php.ini file. Alternatively you could try putting

Code: Select all

<?php phpinfo(); ?>
into a file and running it. That'll tell you everything you need to know about how PHP is configured and what's been enabled and what hasn't (and you can look at this even if you don't have access to the php.ini file, if for example you want to look at your host's PHP config).

Mac
nike
Forum Newbie
Posts: 14
Joined: Mon Apr 29, 2002 1:38 pm

Thank you

Post by nike »

Hi,
thank you for the info.
I knew that phpinfo thingy ;-)
I just needed the iniget Volka supplied - thank you for that one Volka -

Bye

Nike

P.S. Sorry, the next time I´ll read the manual
even more thoroughly - promise.
Post Reply