Example
Inherit from a class:
html
<?php
class MyClass {
public function hello() {
echo
"Hello
World!";
}
}
class AnotherClass extends MyClass {
}
$obj = new
AnotherClass();
$obj->hello();
?>
Definition and Usage
The extends keyword is used to derive a class from another class. This is called inheritance. A derived class has all of the public and protected properties of the class that it is derived from.