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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to