Posted by alexander.petrov on 01/24/08 07:38
Well, I think it is more prejudice than real danger. If you read more
carefully my last post I am barely mentioning 2 types of "global"
variables.
1. This is the danger one. It can be used if register_globals = On. Of
course I will never turn it On. The security hole is well known.
2. If we define "global ConfigSettings" this way we can have it
accessible from everywhere and it is very convenient way to use it
without passing it as parameter to every function. I do not see any
danger here. I have read articles like this one
http://blog.case.edu/gps10/2006/07/22/why_global_variables_in_php_is_bad_programming_practice
and reasons like:
- The downside to using global configuration variables is that they
can be modified from anywhere in the program
- All it takes is one unknowing programmer...
- The reason is that dependence on global object instances limits the
flexibility of your program
are not serious for me. I already did a workbench using global and
registry pattern approach and the later is a bit slower, so I would be
thankful if one can provide me with any info that brings the real
downside.
[Back to original message]
|