Testing for a Function's Existence : function_exists « Functions « PHP






Testing for a Function's Existence

 
<html>
<body>
<div>
<?php
    function tagWrap( $tag, $txt, $func="" ) {
      if ( function_exists( $func ) )
        $txt = $func( $txt );
      return "<$tag>$txt</$tag>\n";
    }
    
    function subscript( $txt ) {
      return "<sub>$txt</sub>";
    }
    
    print tagWrap('b', 'bold');
    
    print tagWrap('i', 'i', "subscript");
   
?>
</div>
</body>
</html>
  
  








Related examples in the same category

1.bool function_exists ( string function_name ) returns true if that function is available for use.