Implement an interface : Interface « Class « PHP






Implement an interface


<?php
interface Chargeable {
    public function getPrice();
}

class Employee implements Chargeable {
    protected $price;

    public function getPrice() {
        return $this->price;
    }
}

$product = new Employee();

?>

           
       








Related examples in the same category

1.Different class implements one interface
2.A Sample Interface
3.Implementing Multiple Interfaces
4.Defining an interface
5.Defining and Using an Interface
6.Using Type Hinting with Interfaces