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

Source: Internet
Author: User
Tags imap
The function described in this article is actually the PHP manual, but because these functions are more independent, easy to find, so separate introduction, convenient to consult.
1. Get all available modules-get_loaded_extensions This function returns all loaded (available) modules.
Usage:
Copy CodeThe code is as follows:
Print_r (Get_loaded_extensions ());

2. Gets the available functions for the specified module-Get_extension_funcs The function returns all available functions for the specified module. The parameter passed in (module name) must be lowercase
Usage:
Copy CodeThe code is as follows:
Print_r (Get_extension_funcs ("GD"));

3. Get all defined functions-get_defined_functions This function returns all functions that have been defined, including built-in functions and user-defined functions.
Usage:
Copy CodeThe code is as follows:
function Myrow ($id, $data) {
Return "$id$data\ n ";
}
$arr = Get_defined_functions ();
Print_r ($arr);

Output:
Copy CodeThe code is 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
...
[+] = Bcscale
[751] = Bccomp
)
[User] = Array
(
[0] = Myrow
)
)

where $arr ["internal"] is a built-in function, $arr ["User"] is a user-defined function.
4. Check if the specified function exists-function_exists The function returns whether the specified function has already been defined.
Usage:
Copy CodeThe code is as follows:
if (function_exists (' Imap_open ')) {
echo "IMAP functions is available.
\ n ";
} else {
echo "IMAP functions is not available.
\ n ";
}

http://www.bkjia.com/PHPjc/321617.html www.bkjia.com true http://www.bkjia.com/PHPjc/321617.html techarticle the function described in this article is actually the PHP manual, but because these functions are more independent, easy to find, so separate introduction, convenient to consult. 1. Get all the available ...

  • 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.