Home > Backend Development > PHP Tutorial > PHP code to check whether extension library or function is available_PHP tutorial

PHP code to check whether extension library or function is available_PHP tutorial

WBOY
Release: 2016-07-21 15:39:08
Original
899 people have browsed it

The functions introduced in this article are actually in the PHP manual. However, because these functions are highly independent and difficult to find, they are introduced separately for easy reference.
1. Get all available modules - get_loaded_extensions This function returns all loaded (available) modules.
Usage:

Copy code The code is as follows:

print_r(get_loaded_extensions());

2. Get the available functions of the specified module - get_extension_funcs This function returns all available functions of the specified module. The passed-in parameters (module name) must be lowercase
Usage:
Copy code The code is as follows:

print_r( get_extension_funcs("gd"));

3. Get all defined functions - get_defined_functions This function returns all defined functions, including built-in functions and user-defined functions.
Usage:
Copy code The code is as follows:

function myrow($id, $data){
return "$id$datan";
}
$arr = get_defined_functions();
print_r($arr);

Output:
Copy code The code is as follows:

Array
(
[internal] => Array
(
[0] => zend_version
[1] => func_num_args
[2] => 🎜>[3] => func_get_args
[4] => strlen
[5] => strcmp
[6] => strncmp
...
[750 ] => bcscale
[751] => bccomp
)
[user] => Array
(
[0] => myrow
)
)

Where $arr["internal"] is a built-in function and $arr["user"] is a user-defined function.
4. Check whether the specified function exists - function_exists This function returns whether the specified function has been defined.
Usage:

Copy code The code is as follows:
if (function_exists('imap_open')) {
echo "IMAP functions are available.
n";
} else {
echo "IMAP functions are not available.
n";
}

http://www.bkjia.com/PHPjc/321617.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321617.htmlTechArticleThe functions introduced in this article are actually already in the PHP manual. However, due to the strong independence of these functions, search It’s not easy, so I’ll introduce it separately for easy reference. 1. Get all available...
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