Core PHP

Get the Defined Functions

This PHP program demonstrates how to print all of the defined functions.

GetDefinedFunctions.php

<?php

  // Two user-defined functions
  function fnHello() {
    echo "Hello";
  }

  function fnWorld() {
    echo "World";
  }

  $qaaFunctions = get_defined_functions();

  // Loop over each set of functions
  foreach($qaaFunctions as $sMainKey => $qaFunctions) {

    // Make the heading for each group of functions
    echo "<ul><h3>".$sMainKey."</h3>";

    // Loop over the functions in the group
    foreach($qaFunctions as $sKey =>$sFunction) {
      echo "<li>".$sKey." => ".$sFunction."</li>";
    }
    echo "</ul>";
  }

?>
 

Output

 
 

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