TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-27-2008, 03:15 PM   #1 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Bug 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:
$iX = 2;
$iY = 3;

function multiply()
{
    global $iX, $iY;
    return $iX * $iY;
}

echo 'Total: ' . multiply();

However, I really cannot remember the last time I used that in any of my scripts - thanks to OOP! How about everybody else?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 01-27-2008, 04:20 PM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

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.
Salathe is offline  
Reply With Quote
Old 01-27-2008, 05:24 PM   #3 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

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
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 01-27-2008, 05:25 PM   #4 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Would you say Wordpress is badly coded?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 01-27-2008, 05:39 PM   #5 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Wordpress isn't "badly" coded as such, it's just like many large scripts (in particular vBulletin - seen the AdminCP code recently? ) in that it's littered with legacy code that was acceptable back then, but is less acceptable nowadays.

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 01-27-2008, 06:02 PM   #6 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Would you say Wordpress is badly coded?
I'd say it's excessively procedural (even in some cases where an OO approach would have been more appropriate), making it very hard to extend.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 01-28-2008, 05:06 AM   #7 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

I've used it once in my code, then I stopped considering, I felt that it wasn't needed. :/
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 01-28-2008, 05:47 PM   #8 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

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.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 01-28-2008, 06:33 PM   #9 (permalink)
The Addict
Top Contributor Good Samaritan 
 
Join Date: Jan 2008
Location: USA
Posts: 217
Thanks: 16
RobertK is on a distinguished road
Default

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.
__________________
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
RobertK is offline  
Reply With Quote
Old 01-28-2008, 07:12 PM   #10 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

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).
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 01-28-2008, 07:53 PM   #11 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Would you say Wordpress is badly coded?
By all means, yes.

On subject, I cant remember the last time I used it.
__________________

Village Idiot is offline  
Reply With Quote
Old 01-28-2008, 08:41 PM   #12 (permalink)
The Addict
Top Contributor Good Samaritan 
 
Join Date: Jan 2008
Location: USA
Posts: 217
Thanks: 16
RobertK is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Would you say Wordpress is badly coded?
In my own past uses I would say "kind of". Obviously it has an aging code base, and isn't been refactored into more efficient or relevant code. This lack of finesse for relatively simplistic things is a bad sign of what PHP can do, but ultimately not our responsibility. And yes, that's why I decided to make my own blog package for my own personal use, perhaps for others too, because I hate weighty packages for simplistic things. And secure software needn't be weighty, just secure!

So, badly coded ... sorta. But yet it does function and is popular.
__________________
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
RobertK is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:17 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design