337 of 410 menu

The get_declared_interfaces Function

The get_declared_interfaces function returns an array of names of all interfaces that have been declared in the current script or loaded through autoloading. The function does not accept any parameters.

Syntax

get_declared_interfaces();

Example

Get the list of all declared interfaces:

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

Code execution result:

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

Example

Check if the list contains a specific interface:

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

Code execution result:

true

Example

Compare the list of interfaces before and after declaring a new interface:

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

Code execution result:

['NewInterface']

See Also

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline