News Feed
Sections




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

Russell Walker:
Handling Global Data in PHP Web Applications
September 16, 2013 @ 12:31:07

Russell Walker has a post on his site sharing some suggestions about effectively dealing with global data in your PHP applications.

Almost every web application needs to handle global data. There are certain things that just have to be available throughout the entire code base, such as database connections, configuration settings, and error handling routines. As a PHP developer, you may have heard the mantra 'globals are evil', but this naturally begs the question 'what should I use instead of global variables?'

He includes four different options (five including the actual use of global variables):

  • Static classes
  • Singleton
  • Registry
  • Dependency injection

For each of the options he includes summaries of both the advantages and disadvantages as well as some sample code showing their use. Ultimately, he points out that it's up to the developer of the application which option fits best.

0 comments voice your opinion now!
global variable data opinion options registry singleton dependencyinjection static

Link: http://russellscottwalker.blogspot.co.uk/2013_09_07_archive.html

blog comments powered by Disqus

Similar Posts

International PHP Magazine: Poll Question: Which PHP Script Manages FAQs Effectively?

O\'Reilly: Designing a database-driven PHP App? Don\'t Forget the Data!!

James Fuller's Blog: Why canít someone just make a good IDE for PHP?

Harry Fuecks' Blog: Using OpenSSL, RSA and RC4 to exchange encrypted data from PHP to Java

Zend Developer Zone: Automatic Tag Clouds for Every Site


Community Events





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


application community library wordpress release api interview podcast series laravel unittest list symfony install threedevsandamaybe configure language developer introduction code

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