Core PHP

Get the Declared Classes

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

GetDeclaredClasses.php

<?php

  // A simple class
  class CTestClass {
    public function __construct() {
    }
  }

  $qaClasses = get_declared_classes();

  // Display the heading for the classes
  echo "<ul><h3>All Declared Classes</h3>";

  // Loop over the classes
  foreach($qaClasses as $sKey =>$sClass) {
    echo "<li>".$sKey." => ".$sClass."</li>";
  }
  echo "</ul>";

?>
 
 

Output

 
 

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