3.4. Summary

This has been a brief tour of some of the more underutilized areas of PHP's native function set. By using this functionality your code can be more compact and more reliable without sacrificing legibility. Array functions can often be used in place of sometimes complex loops, reducing the task to a single line of code and a helper function that can be captured and stored in a library for reuse. Function-handling functions allow you to decide at runtime not only which function you wish to use (a switch statement could do that), but also decide which functions are in this list you wish to select from, or even create the function from scratch. Streams allow you to hide the implementation details of how external data is read or written, allowing the rest of your program to be able to treat it as just another file.

There are always new features being added to PHP—new initialization settings to fine-tune its operation, new arguments to existing functions that enhance their utility (even the venerable function str_replace() has been given a new argument in PHP5), new functions, and even whole new categories of functions. All this makes learning PHP an ongoing affair in which there is always something you don't know about yet.

Get Professional LAMP: Linux®, Apache, MySQL®, and PHP5 Web Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.