Object-oriented programming provides many advantages over procedural programming. It helps with encapsulation when code is shared within a team or between teams and it can help protect elements of the code from being abused. This is especially the case when code is shared in compiled form but the same mechanisms can be applied to a scripting language like PHP. This chapter describes how object-oriented programming works in PHP.
Recipe 2-1. Writing a Simple Class
Problem
PHP can be used as a procedural programming language, but you want to make use of the many features of object-oriented ...