Creating your own PHP classes is remarkably simple. As I explained in the previous chapter, a class is basically a collection of related variables and functions surrounded by a pair of curly braces and labeled with the class name. Of course, there is more to it than that, so this chapter explains the finer details.

By the end of this chapter, you should have a good understanding of the following:

  • Creating a class and instantiating objects from it

  • Controlling access to class properties and methods with visibility modifiers

  • Creating a subclass and overriding its parent's properties and methods

  • Preventing a class, its properties, ...

Get PHP Object-Oriented Solutions now with O’Reilly online learning.

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