class_implements ක්රියාව
class_implements ක්රියාව විසින් නිශ්චිත පන්තියක් හෝ අතුරුමුහුණතක් ක්රියාත්මක කරන අතුරුමුහුණත් නම්වල අරාවක් ආපසු ලබා දෙයි. පළමු පරාමිතියට වස්තුවක් හෝ පන්තියේ නම නූලක් ලෙස ලබා දෙන අතර, දෙවන විකල්ප පරාමිතිය ස්වයංක්රීය ලොඩින් භාවිතා කළ යුතුද යන්න තීරණය කරයි.
වාක්ය රචනා ක්රමය
class_implements(
object|string $class,
[bool $autoload = true]
): array|false
උදාහරණය
ආවේණික පන්තිය Exception සඳහා අතුරුමුහුණත් ලබා ගනිමු:
<?php
$res = class_implements('Exception');
print_r($res);
?>
කේතය ක්රියාත්මක කිරීමේ ප්රතිඵලය:
['Throwable']
උදාහරණය
අපගේම අතුරුමුහුණතක් සහ පන්තියක් සාදා, පසුව ක්රියාත්මක කරන ලද අතුරුමුහුණත් පරීක්ෂා කරමු:
<?php
interface MyInterface {}
class MyClass implements MyInterface {}
$res = class_implements('MyClass');
print_r($res);
?>
කේතය ක්රියාත්මක කිරීමේ ප්රතිඵලය:
['MyInterface']
උදාහරණය
අතුරුමුහුණතක් සඳහාම අතුරුමුහුණත් පරීක්ෂා කරමු:
<?php
interface ParentInterface {}
interface ChildInterface extends ParentInterface {}
$res = class_implements('ChildInterface');
print_r($res);
?>
කේතය ක්රියාත්මක කිරීමේ ප්රතිඵලය:
['ParentInterface']
මෙයද බලන්න
-
class_parentsක්රියාව,
එය මාපිය පන්ති ආපසු ලබා දෙයි -
class_usesක්රියාව,
එය පන්තියක් භාවිතා කරන ගුණාංග (traits) ආපසු ලබා දෙයි