Core PHP

Get the Declared Interfaces

This PHP program demonstrates how to print all of the declared interfaces in PHP.

GetDeclaredInterfaces.php

<?php

  // A simple class
  interface ITestInterface {
    public function Add(int $i, int $j) : int;
  }

  $qaInterfaces = get_declared_interfaces();

  // Display the heading for the interfaces
  echo "<ul><h3>All Declared Interfaces</h3>";

  // Loop over the interfaces
  foreach($qaInterfaces as $sKey =>$sInterface) {
    echo "<li>".$sKey." => ".$sInterface."</li>";
  }
  echo "</ul>";

?>
 
 

Output

 
 

© 2007–2024 XoaX.net LLC. All rights reserved.