Home > Backend Development > PHP Tutorial > A deep dive into the methods available for PHP inspection functions_PHP Tutorial

A deep dive into the methods available for PHP inspection functions_PHP Tutorial

WBOY
Release: 2016-07-15 13:33:51
Original
832 people have browsed it

We are using

PHP to check that the function is available 1. Get all available modules - get_loaded_extensions
This function returns all loaded (available) modules.

Usage:

print_r(get_loaded_extensions());

PHP check function available 2. Get the available functions of the specified module - get_extension_funcs
This function returns all the functions of the specified module Available functions. The incoming parameters (module name) must be lowercase

Usage:

print_r(get_extension_funcs("gd"));

PHP check function available 3. Get all the functions that have been Defined functions - get_defined_functions
This function returns all defined functions, including built-in functions and user-defined functions.

Usage:

<ol class="dp-xml">
<li class="alt"><span><span>function myrow($id, $data){   </span></span></li>
<li>
<span>return "</span><span class="tag"><</span><span class="tag-name">tr</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">th</span><span class="tag">></span><span>$id</span><span class="tag"></</span><span class="tag-name">th</span><span class="tag">></span><span class="tag"><</span><span class="tag-name">td</span><span class="tag">></span><span>$data</span><span class="tag"></</span><span class="tag-name">td</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">tr</span><span class="tag">></span><span>n";   </span>
</li>
<li class="alt"><span>}   </span></li>
<li>
<span>$</span><span class="attribute">arr</span><span> = </span><span class="attribute-value">get_defined_functions</span><span>();   </span>
</li>
<li class="alt"><span>print_r($arr);   </span></li>
</ol>
Copy after login

Output:

<ol class="dp-xml">
<li class="alt"><span><span>Array   </span></span></li>
<li><span>(   </span></li>
<li class="alt">
<span>[internal] =</span><span class="tag">></span><span> Array   </span>
</li>
<li><span>(   </span></li>
<li class="alt">
<span>[0] =</span><span class="tag">></span><span> zend_version   </span>
</li>
<li>
<span>[1] =</span><span class="tag">></span><span> func_num_args   </span>
</li>
<li class="alt">
<span>[2] =</span><span class="tag">></span><span> func_get_arg   </span>
</li>
<li>
<span>[3] =</span><span class="tag">></span><span> func_get_args   </span>
</li>
<li class="alt">
<span>[4] =</span><span class="tag">></span><span> strlen   </span>
</li>
<li>
<span>[5] =</span><span class="tag">></span><span> strcmp   </span>
</li>
<li class="alt">
<span>[6] =</span><span class="tag">></span><span> strncmp   </span>
</li>
<li><span>...   </span></li>
<li class="alt">
<span>[750] =</span><span class="tag">></span><span> bcscale   </span>
</li>
<li>
<span>[751] =</span><span class="tag">></span><span> bccomp   </span>
</li>
<li class="alt"><span>)   </span></li>
<li>
<span>[user] =</span><span class="tag">></span><span> Array   </span>
</li>
<li class="alt"><span>(   </span></li>
<li>
<span>[0] =</span><span class="tag">></span><span> myrow   </span>
</li>
<li class="alt"><span>)   </span></li>
<li><span>)  </span></li>
</ol>
Copy after login

where $arr["internal"] is the built-in Function, $arr["user"] is a user-defined function.

PHP check function available 4. Check whether the specified function exists - function_exists

This function returns whether the specified function has been defined.

Usage:

<ol class="dp-xml">
<li class="alt"><span><span>if (function_exists('imap_open')) {   </span></span></li>
<li>
<span>echo "IMAP functions are available.</span><span class="tag"><</span><span class="tag-name">br</span><span> </span><span class="tag">/></span><span>n";   </span>
</li>
<li class="alt"><span>} else {   </span></li>
<li>
<span>echo "IMAP functions are not available.</span><span class="tag"><</span><span class="tag-name">br</span><span> </span><span class="tag">/></span><span>n";  </span>
</li>
</ol>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446021.htmlTechArticleWe are using PHP to check that the function is available 1. Get all available modules - get_loaded_extensions This function returns all loaded ( available) modules. Usage: print_r(get_loade...
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