|
Posted by Steve on 03/27/07 13:17
"Christoph Burschka" <christoph.burschka@rwth-aachen.de> wrote in message
news:56sheiF29re4hU1@mid.dfncis.de...
|
|
| J.O. Aho schrieb:
| >
| >>secondly, the variable needs to
| >>be declared global both inside and outside of the function if they are
| >>to share the same scope.
| >
| >
| > It seems that the PHP documentaion disagrees with you
| > http://www.php.net/global
| >
| > Both examples works (if removing the $ infront of global in example 1)
| >
| >
|
| Wow, I didn't know that. So all those commands declaring global
| variables outside functions were redundant... well, you never quit
learning.
while i too was about to say 'you're wrong', i do still tend to put 'global'
with variables i know i'll be using else where, if nothing else but to give
some kind of hint to the other developers that it is called within other
scopes - i.e. they may see it in a function though not passed in.
i completely avoid globals as they are very uninformative to other
developers (or myself after not working with a piece of code for a while).
and, while globals are effectively the same as a static interface on a class
object, at least that interface has a definitive structure with related
logic that will keep me from changing a property to something that is
completely invalid outside of local scope.
but that's just my 0.02 usd.
Navigation:
[Reply to this message]
|