1. New SPL Features in PHP 5.3
Matthew Turland
CodeWorks '09 Webcast Series
June 26, 2009
2. Salut! Comment sa-va?
●
Senior Consultant at Blue Parabola
● Native of Duson, Louisiana
● Author and TE for php|architect Magazine
● Book coming soon from php|architect
● Contributor to Zend Framework project
3. A Long, Long Time Ago (Or Not)
● Alexander Stepanov
● Conceived of the
STL for C++
●
Goals of SPL are
somewhat similar
4. In a Galaxy Not So Far Away
Pre-5.3 SPL Features
● Classes: ArrayObject, SplFileInfo...
● Interfaces: ArrayAccess, Countable...
● Exceptions: BadFunctionCallException...
● Functions: spl_autoload_register...
6. So What's New?
In comparison to the STL:
● Iterators? Nope.
● Algorithms? Nope.
● Functors? Nope.
● Well, there's only one thing left then...
7. Containers
“A container is a class, a data structure,
or an abstract data type whose instances
are collections of other objects. They are
used to store objects in an organized way
following specific access rules.”
“Container (data structure)” - Wikipedia
8. We Don't Need
No Stinkin' Containers!
array() 'string'
14. SplFixedArray
● Like an array, but with a fixed length.
● Only allows integers >= 0 for keys.
● Can be resized, but at a cost.
● Great for simple enumerated lists.
37. SplPriorityQueue
● Operates similarly to a heap
● In fact, uses a heap internally for storage
● Accepts a priority with the element value
● Element with highest priority comes out first
43. Some Great SPL Resources
●
http://php.net/spl
● http://colder.ch
●
http://blueparabola.com/blog/spl-deserves-some-reiteration
●
http://elizabethmariesmith.com/slides/spl_to_the_rescue.pdf
44. C'est tous!
●
http://ishouldbecoding.com
● http://www.blueparabola.com/blogs/matthew-turland
● matt@ishouldbecoding.com or matthew@blueparabola.com
● Elazar on the Freenode IRC network
● Look for me in Dallas, Atlanta, Miami,
Washington, and New York City
at CodeWorks 2009!
● Watch for my book next quarter!
Source: Christian Flickinger