News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Brandon Savage's Blog:
Superglobals In Classes Revisited
July 14, 2009 @ 07:51:11

Revisiting an earlier post dealing with superglobals and classes, Brandon Savage looks at an example of why its still a bad idea.

I asserted at the time that superglobals inside of a class violated some basic rules on what a class was supposed to do. Today, I am revisiting that discussion. The placement of superglobals inside a class creates an impossible situation for code reuse. [...] Ehat happens when we want to move this [code] to another site? Unless we leave our form fields named [the same] we'll have to modify the original code.

His alternative - a much better refactoring - lets the verifyCredentials method take in the username and password and has the calling script define where those come from, either from a local or global location.

0 comments voice your opinion now!
refactor revisit class superglobal


blog comments powered by Disqus

Similar Posts

David Otton's Blog: Neat PHP Tricks: How To Assign References to Globals

Wouter Lagerweij's Blog: Reading Up: Books Every Programmer Should Read

PHPMaster.com: Practical Code Refactoring, Part 4 - Efficiency

PHPied.com: SAP container for PEAR::Auth

Leonid Mamchenkov: CakePHP 3, here we go again.


Community Events





Don't see your event here?
Let us know!


introduction list application threedevsandamaybe wordpress language laravel library framework series interview developer release community api project configure bugfix code podcast

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework