Archive for March 19th, 2007

DevShed:Working with Template Classes in PHP 5

DevShed looks at another in their series of design patterns with this new article - a look at one of the simpler, more popular methods, the Template pattern.

A template class is a base class with some special abilities. First, it concretely implements one or more algorithms; second, it can determine which subclasses should use these algorithms. This article is the first part of a two-part series that introduces you to the basic concepts of this design pattern.

They create two simple classes that interface with MySQL to grab the template data from the database. On top of this, they build out a version of teh Template class, a set of methods to grab the formatted rows and return them back to the script. Finally, they use these results with a few helper classes (one for paragraphs, one for div tags) and create an example that outputs the formatted database information.

Continue Reading · Add comment

Working with Template Classes in PHP 5

A template class is a base class with some special abilities. First it concretely implements one or more algorithms second it can determine which subclasses should use these algorithms. This article is the first part of a two-part series that introduces you to the basic concepts of this design pattern….

Search Site Optimized for Developers and IT Pros Fast and relevant. Find technical documents, podcasts, whitepapers, research and blog posts.

Continue Reading · Add comment

Zend Developer Zone: Security Tips #10, #11, and #12

The Zend Developer Zone has posted three new helpful security tips to add to their growing list - one on mailing, one about working with privileges, and the other on the dangers of eval:

  • In tip #10, Cal looks briefly at some of the dangers of blindly using form input when sending a mail. One never knows what kind of nasty headers a user might enter.
  • Tip #11 recommends the “path of least privileges” when it comes to allowing access to your application. Don’t go global when simple will do just fine - even with the best of intentions, the wrong access can lead to big issues.
  • Finally, in tip #12, one of the more discouraged functions in PHP is discussed - eval. This one little function, when fed the wrong kind of string, can unravel your application from the inside out and provide a would-be attacker just the opening they might need.

You can check out more great security tips like these on the Zend Developer Zone website.

Continue Reading · Add comment

Stubbles Blog: Lazy loading of classes stored in a session without __autoload()

On the Stubbles blog today, there’s a warning from Frank Kleine about using the session.auto_start setting in your PHP installation and it preventing you from working with objects. As per the PHP manual:

If you do turn on session.auto_start then you cannot put objects into your sessions since the class definition has to be loaded before starting the session in order to recreate the objects in your session.

Frank points out that this also includes calling session_start before defining other classes to be used. They’ve come up with their own solution, though, using a base interface object for all of their classes. This object is included in each of the pages, eliminating the worry about having multiple objects and classes to mess with.

Continue Reading · Add comment

IBM developerWorks: Command-line PHP? Yes, you can!

On the IBM developerWorks website, there’s a new article that works to show some of the benefits of working with PHP code on the command line and some helpful ways to debug the code.

Of course, just the fact that you can use PHP on the command line isn’t necessarily the best reason for doing so. However, you might quickly find several pleasant surprises when you first begin to experiment with PHP in this way. […] In fact, there’s really nothing stopping you from using PHP as your Swiss Army knife for almost any given programming project.

They walk through the installation and a sample of the debugging before getting into the more complex methods of finding and fixing errors, using the PHP I/O channels and the creation of your first command-line script (including the use of arguments).

Continue Reading · Add comment