How can you implement multiple interfaces in PHP

In PHP, a class can implement multiple interfaces by separating them with a comma in the class declaration. This allows the class to define the methods required by each interface. Below is an example demonstrating how to implement multiple interfaces in PHP.

<?php interface InterfaceA { public function methodA(); } interface InterfaceB { public function methodB(); } class MyClass implements InterfaceA, InterfaceB { public function methodA() { return "Method A implemented."; } public function methodB() { return "Method B implemented."; } } $obj = new MyClass(); echo $obj->methodA(); // Outputs: Method A implemented. echo $obj->methodB(); // Outputs: Method B implemented. ?>

PHP interfaces multiple interfaces object-oriented programming PHP example