In terms of security, or in my opinion, good and proper coding, it is best to have no global variables. There is always a way to wrap variables that will be needed in local scopes. However, this philosophy is harder to practice than it is to preach. Code can get ugly when passing if you are not strong in your coding designing abilities.

Sometime it just becomes easier to attempt to keep as much out of the global scope as possible and suffer the idea of some of them being globally available.

That being said, if someone was to exploit a script that had global or local access to a variable storing database connection info, then the consequences could be drastic. Similar situations are easly applicable as well, with any crucial data or passwords etc.

You should consider reading the section entitled,
"Security: New Input Mechanism" here: http://www.php.net/release_4_1_0.php

Regards,
Jason k Larson


Dara Dowd wrote:

Is it "better" to pass variables through functions or to simply declare them as global within the function's scope?
The variables in this particular case are things like MySQL database connections and tablenames.
Thanks,Dara


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

Reply via email to