Inheritance

Inheritance is a mechanism where a class is build from another class, and form a hierarchy of classes that share a set of attributes and methods.

<?php

class x {
    public function foo() {
        echo "I am foo!\n";
    }
}

class y extends x {
    public function boo() {
        echo "I am boo!\n";
    }
}

$y = new Y();
$y->boo(); // calling the boo method, defined only with y
$y->foo(); // calling the foo method, defined in x, and inherited in y

?>

Documentation

See also This is why PHP don’t have multiple inheritance.

Related : Class, Class Hierarchy, Composition, Constructor, Operator Overloading, Overwrite, Base Class, Base, Method Resolution Order (MRO), Polymorphism