Not the Da Vinci Code

We'll reproduce the code here and intersperse it with comments. (If you would like an overview of the entire class, now would be a good time to download the code for this chapter from the companion website at http://objectorientedphp.com.)

In order to create a class, use the keyword class and an appropriate name:

class DirectoryItems{ ... }

Braces enclose all the elements of a class, indicated by the ellipsis in the preceding line of code.

We discussed the concept of a class in Chapters 2 and 3, but a bit of repetition here won't be amiss. In its simplest form, a class can simply encapsulate a variety of data types, the way a struct does in C or a type in Visual Basic. This class will encapsulate data types, but it will ...

Get Object-Oriented PHP 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.