PHP method to detect whether a function exists through function_exists, phpfunction_exists_PHP tutorial

WBOY
Release: 2016-07-13 10:02:46
Original
1075 people have browsed it

php method to detect the existence of a function through function_exists, phpfunction_exists

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";
}
Copy after login

Usage examples are as follows:

echo textWrap('i','function exists Demo','highlight');
//输出结果为斜体字的: function exists Demo
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969497.htmlTechArticlephp method to detect the existence of a function through function_exists, phpfunction_exists This article describes the method of php to detect the existence of a function through function_exists . Share it with everyone for everyone...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template