Chapter 2. WRITING PHP CLASSES

WRITING PHP CLASSES

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.