function class_implements

Function class_implements သည် သတ်မှတ်ထားသော class သို့မဟုတ် interface တစ်ခုက implement လုပ်ထားသော interface များ၏ အမည်များပါဝင်သည့် array တစ်ခုကို ပြန်ပေးသည်။ ပထမပိုင်း parameter တွင် object သို့မဟုတ် string အနေဖြင့် class အမည်ကို ပေးရပြီး၊ ဒုတိယမြောက် မဖြစ်မနေပေးရန် မလိုအပ်သော parameter သည် autoload ကို အသုံးပြုသင့်၊မပြုသင့် သတ်မှတ်ပေးသည်။

Syntax

phpclass_implements(
  object|string $class,
  [bool $autoload = true]
): array|false

ဥပမာ

Built-in class Exception အတွက် interface များကို ရယူကြည့်ရအောင်။

php<?php
  $res = class_implements('Exception');
  print_r($res);
?>

Code run ပြီးနောက်ရလဒ်။

php['Throwable']

ဥပမာ

ကိုယ်ပိုင် interface တစ်ခုနှင့် class တစ်ခုကို ဖန်တီးပြီး၊ ထို့နောက် implement လုပ်ထားသော interface များကို စစ်ဆေးကြည့်ရအောင်။

php<?php
  interface MyInterface {}
  class MyClass implements MyInterface {}
  
  $res = class_implements('MyClass');
  print_r($res);
?>

Code run ပြီးနောက်ရလဒ်။

php['MyInterface']

ဥပမာ

Interface ကိုယ်တိုင်အတွက် interface များကို စစ်ဆေးကြည့်ရအောင်။

php<?php
  interface ParentInterface {}
  interface ChildInterface extends ParentInterface {}
  
  $res = class_implements('ChildInterface');
  print_r($res);
?>

Code run ပြီးနောက်ရလဒ်။

php['ParentInterface']

ဆက်လက်ကြည့်ရှုရန်

  • function class_parents,
    သည် parent class များကို ပြန်ပေးသည်
  • function class_uses,
    သည် class တစ်ခု အသုံးပြုထားသော trait များကို ပြန်ပေးသည်