Chapter 4. Working with PHP Object-Oriented Programming

In this chapter we will cover:

  • Developing classes
  • Extending classes
  • Using static properties and methods
  • Using namespaces
  • Defining visibility
  • Using interfaces
  • Using traits
  • Implementing anonymous classes

Introduction

In this chapter, we will consider recipes that take advantage of the object-oriented programming (OOP) capabilities available in PHP 7.0, 7.1, and above. Most of the OOP functionality available in PHP 7.x is also available in PHP 5.6. A new feature introduced in PHP 7 is support for anonymous classes. In PHP 7.1, you can modify the visibility of class constants.

Note

Another radically new feature is the ability to catch certain types of error. This is discussed in greater detail in Chapter ...

Get PHP 7 Programming Cookbook 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.