Object Inheritance
One of the ways in which objects make programming faster is the ability to use one object to create a second object with expanded variables and functions. This is referred to as object inheritance.
Going back to the Human example, if the Human class has the attributes gender, height, weight, and birth date and it has the methods eating and sleeping, you could create another class called Adult that is an extension of Human. Along with the aforementioned variables and functions, an Adult object might also have the attribute of married and the method of working. As a rule, the child of a parent class inherits all the properties of the parent and then adds some new ones.
To make a child class from a parent, you use the extends ...
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.