Turn OFF register_globals in PHP

Having now used two different hosting companies for PHP web site hosting, I would like to quick describe the configuration issue that have occured with both hosting companies. They both set PHP's register_globals configuration variable to On, which can have undesirable effects on your application and make you easily second guess why your application is behaving in a certain way.

When register_globals is set to On, this means that your variables are registered globally and available on every page. So if you declare a variable called $userCount and assign it some value in a page called script1.php and then have another variable with the same name ($userCount) but with a different meaning on another page (say script2.php), it will initially take the value assigned when script1.php was executed!

So let's say script1.php performed the following assignment:

$userCount = 5;

When script2.php executes, if it also has a variable called $userCount, its initial value will be 5! Very confusing!

So take my advice, if you can configure PHP yourself on your web hosting site, then set register_globals to Off, or ask your web hosting company to do this for you. 

Also note that the register_globals configuration variable has been removed as of PHP version 5.4.


Anonymous said...

Hey there! I am aware this is to some degree off-topic even
so needed to check with. Will running a well-established
blog just like yours have a great deal of perform?
I am brand new so that you can blogging and site-building on the
other hand complete compose at my diary daily.
I’d choose to find a weblog so i could write about our knowledge plus opinions online.

Be sure to let me know for those who have
every guidelines or maybe tips for brand new aspiring site masters.
Feel free to surf my web blog ... Public Records

Anonymous said...

I am surе this рost has tоuched all the іnteгnet peοple,
its гeally really good article on building up new web site.

Feеl free to visіt my website - payday loans

Blogger said...

Bluehost is definitely one of the best website hosting company with plans for any hosting requirments.