ep13_oop_interfaces.php
<?php
interface PaymentMethod {
function pay();
function status();
}
class CreditCard implements PaymentMethod{
public function pay(){
return "The payment is done by Credit Card.";
}
public function status(){
return "The payment is successfully processed.";
}
}
class UPI implements PaymentMethod{
public function pay(){
return "The payment is done by UPI.";
}
public function status(){
return "The payment is successfully processed.";
}
}
class NetBanking implements PaymentMethod{
public function pay(){
return "The payment is done by Net Banking.";
}
public function status(){
return "The payment is successfully processed.";
}
}
// this can be used with any class that implements PaymentMethod
function checkout(PaymentMethod $method){
return $method->pay() . " " . $method->status();
}
echo checkout(new CreditCard());
Output
Output for this tutorial goes here.
The payment is done by Credit Card. The payment is successfully processed.
The payment is done by UPI. The payment is successfully processed.
The payment is done by Net Banking. The payment is successfully processed.