I have certain PHP class methods that access external variables. These variables are not passed as arguments, but rather directly used by the code in the methods.
One method uses a variable that is DEFINEd in a config file and whose purpose is to be available to every part of the app that needs it. This seems ok to me.
The other method directly accesses a $_GET var. There is code that handles the case where this var is not set, but somehow this smells to me.
Are these two cases something I should be doing or should I have a strict pass-as-argument convention?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…