PHP Check if the extension library or function is available code _php tips

Source: Internet
Author: User
Tags imap
This article describes the function is actually a PHP manual, but because these functions are strong independence, find not easy, so a separate introduction, convenient access.
1. Get all available modules-get_loaded_extensions This function returns all the (available) modules that have been loaded.
Usage:
Copy Code code as follows:

Print_r (Get_loaded_extensions ());

2. Get the available functions for the specified module-Get_extension_funcs This function returns all available functions for the specified module. Parameters passed in (module name) must be lowercase
Usage:
Copy Code code as follows:

Print_r (Get_extension_funcs ("GD"));

3. Get all the defined functions-get_defined_functions This function returns all the functions that have been defined, including built-in functions and user-defined functions.
Usage:
Copy Code code as follows:

function Myrow ($id, $data) {
Return "<tr><th> $id </th><td> $data </td></tr>\n";
}
$arr = Get_defined_functions ();
Print_r ($arr);

Output:
Copy Code code as follows:

Array
(
[Internal] => Array
(
[0] => zend_version
[1] => Func_num_args
[2] => Func_get_arg
[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, $arr ["User"] is a user-defined function.
4. Check that the specified function exists-function_exists The function returns whether the specified function has been defined.
Usage:
Copy Code code as follows:

if (function_exists (' Imap_open ')) {
echo "IMAP functions are available.<br/>\n";
} else {
echo "IMAP functions are not available.<br/>\n";
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.