Re: Opinion about the using $GLOBALS directly

From: Date: Fri, 21 Dec 2007 18:35:16 +0000
Subject: Re: Opinion about the using $GLOBALS directly
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-266216@lists.php.net to get a copy of this message
On Dec 20, 2007, at 11:24 AM, Sancar Saran wrote:
Hello All, Thanks for joining the conversation. It seems there where no real technical dead end for using $GLOBALS directly. Using $GLOBALS directly very similar to coding standarts. It just up to you. Also I try explain my enviroment a liddle bit. First of all my function declarationgs gonna like this // Set Shorcut Variables $arrConf = &$GLOBALS['_LIVE']['_CONF']; $arrStat = &$GLOBALS['_LIVE']['_STAT']; $arrDomSet = &$GLOBALS['_LIVE']['_DOMN'][$GLOBALS['_LIVE']['_STAT']['curDom']] ['settings']; $arrLang = &$GLOBALS['_LIVE']['_LANG'][$arrStat['language']]; $rootDir = &$arrConf['rootDir'];
$webDir    = &$arrConf['webDir'];
$arrDb     = &$arrConf['_DB'];
$arrDbg    = &$GLOBALS['_LIVE']['_DEBG'];
Why are you using references to the $GLOBALS? If they're global, then there's only 1 instance/reference to it. Seems needless...
It grows and grows. And some times in small functions, function declarations become larger than the function actual code. Most of those GLOBALS usage are read only (like configuration variables, or stored language keys) or need to update anywhere in the system. And unde one condition it may become problem. If 3rd party users develop some code under my enviroment and if there where some change about GLOBALS['name'] or PHP core developers may change GLOBALS to GLB (or someting like that) there may problem to update 3rd party code. To prevent this, putting some variable translation functions for 3rd party developers was good idea. Other than this for my point of view it was very useful. Thank you very much all of you. Sancar
~Philip Thompson "Personally, most of my web applications do not have to factor 13.7 billion years of space drift in to the calculations, so PHP's rand function has been great for me..." ~S. Johnson

« previous php.general (#266216) next »