Page 2 of 2

Posted: Fri Jan 12, 2007 5:07 pm
by Christopher
When you do:

Code: Select all

global $x;
        unset($x);
I believe you are unsetting a reference to the global var ... which is really decrementing the reference count. Whereas I believe $GLOBALS['x'] is the actual var. It is a feature of PHP variables.

Just add these to the reasons that it is not good practice to use global vars. Not much you can do because you are dealing with an existing, poorly coded, application.

Posted: Sat Jan 13, 2007 10:28 am
by dibyendrah
arborint wrote:When you do:

Code: Select all

global $x;
        unset($x);
I believe you are unsetting a reference to the global var ... which is really decrementing the reference count. Whereas I believe $GLOBALS['x'] is the actual var. It is a feature of PHP variables.

Just add these to the reasons that it is not good practice to use global vars. Not much you can do because you are dealing with an existing, poorly coded, application.
Yes, using global is a bad practice and generates security flaws as well.