June 2002
Intermediate to advanced
800 pages
16h 3m
English
Inheritance is a core component of the object-oriented paradigm. With the help of inheritance, it is possible to build short and efficient code. However, if the hierarchy of objects becomes too complex, your applications will be difficult to debug.
Inheritance means that a class can inherit methods and attributes from a parent class. In PHP, a class can only inherit from the parent class—it is not possible for one class to have more than one parent.
After this theoretical overview, you will see an example of a class that inherits from a parent class:
<?php # Class human class human { var $age; var $gender; # Constructor function human($age, $gender) { $this->age = $age; $this->gender = $gender; } function getage() ...Read now
Unlock full access