![]() |
When was the last time you used the global construct?
If you remember, the
global construct allows you to bring in variables to use in a function that didn't declare them. Like so:php Code:
However, I really cannot remember the last time I used that in any of my scripts - thanks to OOP! How about everybody else? |
In my own everyday coding, the use of
global has pretty much vanished. However, recently I've been playing with Wordpress which relies very heavily on some variables in the global scope so global is the usual practice there. |
It's been so long since I've used it that I can't rightly remember, but I'd say at least 2 years ago, probably longer.
Alan |
Would you say Wordpress is badly coded?
|
Wordpress isn't "badly" coded as such, it's just like many large scripts (in particular vBulletin - seen the AdminCP code recently? :-D) in that it's littered with legacy code that was acceptable back then, but is less acceptable nowadays.
Alan |
Quote:
|
I've used it once in my code, then I stopped considering, I felt that it wasn't needed. :/
|
I might be the retarded farmer here but I still use globals in my email function. Since I am retrieving the system email and system administrator globally, I am going to set them for my function.
... What would be an alternative. I am here to learn so ... gimme some feedback on that one. I have no idea what the alternative could be. I assume you will want to retrieve some information and not do a query every time a for loop runs though the function. |
In my procedural projects, smaller things, I certainly do use it for handling the Database reference. However it is an object in most my work, and it frees itself. ;-)
I've not quite figured out the nuances of full on OOP/MVC design just yet. |
And to be on topic, I don't use the construct for my own projects, but I do use it alot at work (where I work with code written even 5 years ago).
|
Quote:
On subject, I cant remember the last time I used it. |
Quote:
So, badly coded ... sorta. But yet it does function and is popular. |
| All times are GMT. The time now is 06:22 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0