O'Reilly logo

PHP Advanced for the World Wide Web: Visual QuickPro Guide by Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required