Creating an Object
Using OOP is a two-step process. The first—defining a class—you just did when you wrote the HtmlTemplate class. The second step is to make use of that class by creating an object (or a class instance).
Going back to my Human class analogy, an instance of this class may be called Jude. Jude's attributes are a gender of male, a height of about 40 inches, a weight of 35 pounds, and a birth date of November 15, 1998. Jude is one instance of the Human class and, as you may have noticed, is also a child. A second instance, Kelsey, has a female gender, a height of nearly 5 feet, a weight of 75 pounds, and a birth date of April 11, 1992. Both Jude and Kelsey are separate objects derived from the same class.
Creating an object is remarkably ...
Get PHP Advanced for the World Wide Web: Visual QuickPro Guide 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.