OOP တွင် PHP ၏ တစ်ခုနှင့်တစ်ခု အမွေဆက်ခံခြင်း

၎င်းတို့ကဲ့သို့ပင် class များ၊ interface များသည် operator extends ကို အသုံးပြု၍ တစ်ခုမှတစ်ခုသို့ အမွေဆက်ခံနိုင်ပါသည်။ ဥပမာတစ်ခုကို ကြည့်ကြပါစို့။ ကျွန်ုပ်တို့တွင် ယခင်သင်ခန်းစာမှ ဤ interface တစ်ခုရှိသည်ဆိုပါစို့-

php<?php
  interface iRectangle
  {
    public function __construct($a, $b);
    public function getSquare();
    public function getPerimeter();
  }
?>

သို့သော် ကျွန်ုပ်တို့တွင် ကျွန်ုပ်တို့၏ interface ၏ method အချို့ကို ဖော်ပြထားသော interface iFigure ရှိပြီးဖြစ်သည်-

iFigure.php<?php
  interface iFigure
  {
    public function getSquare();
    public function getPerimeter();
  }
?>

Interface iRectangle သည် interface iFigure ၏ method များကို အမွေဆက်ခံရန် ပြုလုပ်ကြပါစို့-

iRectangle.php<?php
  interface iRectangle extends iFigure
  {
    public function __construct($a, $b);
  }
?>
Задание 1

getName၊ setName၊ getAge၊ setAge method များဖြင့် interface iUser ကို ပြုလုပ်ပါ။

Задание 2

Interface iUser မှ အမွေဆက်ခံပြီး getSalary နှင့် setSalary method များကို ထပ်မံထည့်သွင်းသော interface iEmployee ကို ပြုလုပ်ပါ။

Задание 3

Interface iEmployee ကို အကောင်အထည်ဖော်သော class Employee ကို ပြုလုပ်ပါ။