Re: Discussion of method -- config files

From: Date: Thu, 19 Jun 2008 17:16:43 +0000
Subject: Re: Discussion of method -- config files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-275628@lists.php.net to get a copy of this message
tedd wrote:
Hi gang: More of a question of method rather than of "right" or "wrong" -- of the two methods mentioned here, which way would be "better" and why?
Initially I used to access global variables using the "global" keyword - function foo() {
    global $bar;
} However if the function code is a bit longer, it gets difficult to see if $bar is still actually used, after some revisions. So I switched to using $GLOBALS. Inside $GLOBALS I store variables, arrays and initiated objects (for instance $DB, for database access) - which I call - $GLOBALS["DB"]->connect; I do not consider it "polluting" - it is there to be used. If your code is part of something bigger, then you need a convention, and if you convention supports this method, it's all right. For some reason I do not like the "::" operator, it's visually too unstable :) Iv

« previous php.general (#275628) next »