Home > Article > Backend Development > PHP method to check whether a library or function is available_PHP tutorial
As the version increases, PHP’s functions become more and more complete, and more and more extension libraries and functions are available. Therefore, we must also consider version compatibility issues when writing programs, and we must also consider the server. (Especially virtual host) Whether the extension library is installed.
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:
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 parameter (module name) must be lowercase
Usage:
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:
function myrow($id, $data){
return "