Re: Discussion of method -- config files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux