The example in this article describes the method of php to detect the existence of a function through function_exists. Share it with everyone for your reference. The specific analysis is as follows:
In PHP, you can use the function_exists() function to detect whether another function exists. You can pass the function name as a string into function_exists to determine whether it still exists
function highlight( $txt ) { return "<sub>$txt</sub>"; } function textWrap( $tag, $txt, $func="" ) { if (function_exists( $func ) ) $txt = $func($txt); return "<$tag>$txt</$tag>\n"; }
Usage examples are as follows:
echo textWrap('i','function exists Demo','highlight'); //输出结果为斜体字的: function exists Demo
I hope this article will be helpful to everyone’s PHP programming design.