Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Abstract Method

An abstract method is a method that has no code. It also uses the abstract option in the syntax.

An abstract method serves as a blueprint for other methods: its host class is intended to be subclassed.

Interfaces only have abstract methods.

Abstract constructors cannot use promoted properties.

<?php

abstract class AbstractClass {
    abstract function trumpet(); // abstract method

    function forage() {
        return 1;
    } // concrete method
}

class ConcreteClass extends AbstractClass{

    function trumpet() {
        return 2;
    } // concrete method

    // No need to redefine the concrete methods.
    // Yet, it is still possible
}

?>

Documentation

See Also