<?php
interface Greeting {
public function sayHello();
}
interface Departure {
public function sayGoodbye();
}
class MyClass implements Greeting, Departure {
public function sayHello() {
echo "Hello, world!\n";
}
public function sayGoodbye() {
echo "Goodbye, world!\n";
}
}
$obj = new MyClass();
$obj->sayHello();
$obj->sayGoodbye();
?>Hello, world!
Goodbye, world!Greeting` and `Departure`, each with one method. We then define a class `MyClass` that implements both of these interfaces and defines the methods required by each. MyClass` and call its methods to output "Hello, world!" and "Goodbye, world!".