News Feed
Sections
News Archive


Community Events
php|tek 2008 PHP Conference



feed this:

Developer Tutorials Blog:
Iterating PHP objects, and readable code too!
0 comments :: posted Tuesday May 06, 2008 @ 14:34:58
voice your opinion now!

The Developer Tutorials blog has a recent post that talks about manipulating objects in PHP with the help of the iterators that the Standard PHP Library has to offer.

It's a generally accepted fact that more readable code is more maintainable and easier for other developers to pick up. [...] Today I'm going to take a look at object iteration, most commonly found in the Standard PHP Library, and explore using the Iterator interface to simplify looping.

The main part of the tutorial shows how to implement the Iterator interface of the SPL to create your own custom methods, theirs being a Database version with methodsfor rewinding, reading and getting the current record you're working with.

tagged with: spl iterator tutorial database implement


IBM developerWorks:
Five more PHP design patterns
0 comments :: posted Friday March 28, 2008 @ 08:49:35
voice your opinion now!

The IBM developerWorks site has a new article posted that talks about design patterns, five of them in particular, that can help to "accelerate your PHP development" and make your code more maintainable down the line.

As an application developer, you can have a lifelong career without ever knowing what any of the patterns are called or how or when they're used. However, I've found that a good working knowledge of these patterns, as well as those introduced in the developerWorks article "Five common PHP design patterns" (see Resources), allows you to do two things: Enable high-bandwidth conversations and reduce painful lessons.

The patterns they talk about in this "five more" article of the series are:

  • Adapter Pattern
  • Iterator Pattern
  • Decorator Pattern
  • Delegate Pattern
  • State Pattern

Diagrams are provided for each of them, showing how they flow along with brief code examples (structures really) to show how that transitions over to actual use.

tagged with: design patterns tutorial adapter iterator decorator delegate state

phpRiot.com:
Using the PHP 5 Iterator interface with Smarty
0 comments :: posted Monday March 10, 2008 @ 09:35:00
voice your opinion now!

On the phpRiot blog, Quentin Zervaas has posted a quick tutorial about using the Iterator interface (part of the Standard PHP Library) together with Smarty to loop through some objects:

The PHP 5 Iterator interface is very useful for defining custom behaviour for looping over objects, however I just noticed that looping over such objects in Smarty will not work correctly. Smarty will in fact cast an object back to an array.

He includes code examples of his problem to illustrate and shows how he got around the problem - a getData() function he defined that just returns the array from the object.

tagged with: iterator interface smarty php5 spl object array

DevShed:
Iterators in the Simplest Sense - Traversing Data Structures in PHP 5
0 comments :: posted Thursday March 23, 2006 @ 07:26:35
voice your opinion now!
Wrapping up their series on Iterators in PHP, DevShed has posted Traversing Data Structures in PHP 5 - a look a combining embedded classes with the SPL to work through your data.

Welcome to the final part of the series "Iterators in the Simplest Sense." In this set of articles, you'll learn the basic concepts of iterators in PHP 4 and PHP 5. The overall learning experience is strongly focused on the practical sense of the topic, so you can start quickly using iterators within your own PHP applications.

In this last article I'll explore the implementation of PHP 5 iterators, by utilizing some of the embedded classes that integrate the powerful SPL package. Thus you can learn quickly how to include these programming structures inside your PHP applications.

They jump right in and start working with the SPL functions to create a simple, readable iterator class ("FileIterator"). They follow this with two examples building on the class - one that works with data from a text file, and the other from a MySQL database.

tagged with: php iterator traversing data structures php5 fileiterator php iterator traversing data structures php5 fileiterator


PHP5 zend release releases conference application package PEAR security code book developer pecl database cakephp ajax mysql framework job zendframework

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