CHAPTER 3Object Basics

Objects and classes lie at the heart of this book, and since the introduction of PHP 5, they lie at the heart of PHP too. In this chapter, I lay down the groundwork for more in-depth work with objects and design by examining PHP's core object-oriented features.

PHP 5 brought with it a radical advance in object-oriented support, so if you are already familiar with PHP 4, you will probably find something new here. If you are new to object-oriented programming, you should read this chapter carefully.

This chapter will cover

  • Classes and objects: Declaring classes and instantiating objects
  • Constructor methods: Automating the setup of your objects
  • Primitive and class types: Why type matters
  • Inheritance: Why we need inheritance ...

Get PHP Objects, Patterns, and Practice, Second Edition 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.