Appendix B. Object-Oriented PHP

 

This appendix covers

  • The PHP object model
  • An introduction to the iterators, arrays, and counting interfaces provided by the Standard PHP Library
  • The basics of software design patterns, including the Singleton and Registry patterns

This appendix will refresh your knowledge of those bits of PHP that you haven’t had a chance to deal with until now. Zend Framework is written in PHP5 and is fully object oriented, and you’ll need to have a reasonable amount of knowledge about OOP in PHP to make sense of it. This chapter is no substitute for a full book, such as PHP in Action by Reiersøl, Baker, and Shiflett, but it should help you enough to get going with Zend Framework.

We’ll look at what makes a class, including the visibility specifiers of public, protected, and private. And because the full power of object orientation is realized when classes are extended, we’ll also investigate the use of abstract classes and interfaces to help document the API for a component.

PHP5 introduced the SPL, a library that allows you to make your classes easier to use. Zend Framework uses SPL internally, so we’ll look at some of the powerful things that are possible with it.

B.1. Object Orientation in PHP

B.2. The SPL

B.3. PHP4

B.4. Software Design Patterns

B.5. Summary