Good SPL intro

Submitted by Larry on 2 October 2007 - 9:20pm

One of PHP 5's coolest features is the Standard PHP Library, or SPL. If you're operating in an OO way, SPL is a great way to easily leverage a huge amount of functionality.

Of course, the main problem is that the official documentation on it sucks. At best it points to an off-site series of class hierarchies. (Technically it's not off-site, but not internal to the manual.)

Fortunately, the Zend Developer Zone has recently posted a really good intro to SPL. It doesn't cover some features, like ArrayAccess (a personal favorite), but it should serve as a good intro to SPL and to OOP for those not familiar with it.

If you're planning to work on Drupal 7, make sure you read it. ;-) This is the sort of place where objects can help, rather than hurt, now that we actually have the ability to use them. Consider it an addendum to the PHP 5 talk at DrupalCon.

fqqdk (not verified)

22 January 2008 - 12:23pm

SPL sucks not only because it isn't documented heavily, but because instances of the fancy ArrayObject and co. can't be used everywhere where a plain php array can be used, eg. with array_* functions (or any functions that take arrays as arguments), and that makes porting existing php code that operates with plain php arrays very hard, because you can't refactor arrays into instances of said classes the way refactoring should be done: in small steps.