alexweber15 Posted September 23, 2008 Share Posted September 23, 2008 as in bad practice? I'm reading "Pro PHP Patterns Frameworks Testing and More" from Apress and the author constantly does that throughout the examples and I've seen it a bit around the forums in some examples... Wasn't it considered bad practice to do that??? Because of superglobals and such? I realize if you can restrain yourself from naming a property "GET, POST or SERVER" (and so on) then you probably wont have a problem but I'm just surprised at the popularity that using underscores to prefix property names has got Quote Link to comment Share on other sites More sharing options...
discomatt Posted September 23, 2008 Share Posted September 23, 2008 Not at all... in 'good practise,' you should have very few variables actually sitting in the global name space, and the chances of them colliding with PHP predefined is extremely low. Usually I see $_varname being used in an object, which should eliminate the possibility of collisions. In the global space, you should use $_prefix_varname. Quote Link to comment Share on other sites More sharing options...
alexweber15 Posted September 24, 2008 Author Share Posted September 24, 2008 Not at all... in 'good practise,' you should have very few variables actually sitting in the global name space, and the chances of them colliding with PHP predefined is extremely low. Usually I see $_varname being used in an object, which should eliminate the possibility of collisions. In the global space, you should use $_prefix_varname. wait so what you're saying is that when you're told to avoid using underscored to prefix variable names it only applies to the global namespace? still don't see the point of using that particular prefix when theres so many other possibilities like just, god forbid, naming variables according to what they store Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.