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