This article mainly introduces how to use function_exists to check whether a function exists in php. The example shows how to use function_exists to check whether a function exists and call related techniques in php, which is of great practical value, for more information about how to use function_exists to check whether a function exists in php, see the example in this article. Share it with you for your reference. The specific analysis is as follows:
In php, you can use the function_exists () function to check whether another function exists. you can pass the function name as a string to function_exists to check whether the function exists.
Function highlight ($ txt) {return "$ txt";} function textWrap ($ tag, $ txt, $ func = "") {if (function_exists ($ func )) $ txt = $ func ($ txt); return "<$ tag> $ txt
\ N ";}
Example:
Echo textWrap ('I', 'function exists demo', 'highlight'); // function exists Demo in italics
I hope this article will help you with php programming.