get_declared_interfaces ශ්‍රිතය

get_declared_interfaces ශ්‍රිතය වත්මන් ස්ක්‍රිප්ටයේ අර්ථ දක්වා ඇති හෝ ස්වයංපෝෂිත භාරය හරහා පූරණය කර ඇති සියලුම අතුරු මුහුණත්වල නම් අරාවක් ආපසු ලබා දෙයි. ශ්‍රිතය පරාමිතීන් ලබා නොගනී.

වාක්‍ය රචනය

phpget_declared_interfaces();

උදාහරණය

අර්ථ දක්වා ඇති සියලුම අතුරු මුහුණත් ලැයිස්තුව ලබා ගනිමු:

php<?php
  interface MyInterface1 {}
  interface MyInterface2 {}
  
  $res = get_declared_interfaces();
  print_r($res);
?>

කේතය ක්‍රියාත්මක කිරීමේ ප්‍රතිඵලය:

php[..., 'MyInterface1', 'MyInterface2']

උදාහරණය

ලැයිස්තුවට නිශ්චිත අතුරු මුහුණතක් අඩංගු දැයි පරීක්ෂා කරමු:

php<?php
  interface LoggerInterface {}
  
  $interfaces = get_declared_interfaces();
  $res = in_array('LoggerInterface', $interfaces);
  var_dump($res);
?>

කේතය ක්‍රියාත්මක කිරීමේ ප්‍රතිඵලය:

phptrue

උදාහරණය

නව අතුරු මුහුණතක් අර්ථ දැක්වීමට පෙර සහ පසු අතුරු මුහුණත් ලැයිස්තු සංසන්දනය කරමු:

php<?php
  $before = get_declared_interfaces();
  interface NewInterface {}
  $after = get_declared_interfaces();
  
  $res = array_diff($after, $before);
  print_r($res);
?>

කේතය ක්‍රියාත්මක කිරීමේ ප්‍රතිඵලය:

php['NewInterface']

බලන්න

  • get_declared_classes ශ්‍රිතය,
    පන්ති ආපසු ලබා දෙයි
  • get_declared_traits ශ්‍රිතය,
    ගුණාංග (traits) ආපසු ලබා දෙයි
  • interface_exists ශ්‍රිතය,
    අතුරු මුහුණත පරීක්ෂා කරයි
  • class_implements ශ්‍රිතය,
    පන්තියක අතුරු මුහුණත් ආපසු ලබා දෙයි