<?php
// define the interface
interface Vehicle {
public function start();
public function stop();
}
// define a class that implements the interface
class Car implements Vehicle {
public function start() {
echo "Car started" . PHP_EOL;
}
public function stop() {
echo "Car stopped" . PHP_EOL;
}
}
// define another class that implements the interface
class Truck implements Vehicle {
public function start() {
echo "Truck started" . PHP_EOL;
}
public function stop() {
echo "Truck stopped" . PHP_EOL;
}
}
// create objects of the classes and call the methods
$car = new Car();
$truck = new Truck();
$car->start();
$car->stop();
$truck->start();
$truck->stop();
?>