In-depth study of available methods for PHP checking functions-PHP Tutorial

Source: Internet
Author: User
In-depth study on the methods available for PHP checks. We are using PHP to check function availability 1. get all available modules-get_loaded_extensions this function returns all loaded (available) modules. Usage: print_r (get_loade we are using

PHP check function availability 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 function of the specified module-get_extension_funcs
This function returns all available functions of the specified module. The input parameter (module name) must be in lowercase.

Usage:

Print_r (get_extension_funcs ("gd "));

PHP check function available 3. get all defined functions-get_defined_functions
This function returns all defined functions, including built-in functions and user-defined functions.

Usage:

 
 
  1. function myrow($id, $data){
  2. return "$id$datan";
  3. }
  4. $arr = get_defined_functions();
  5. print_r($arr);

Output:

 
 
  1. Array
  2. (
  3. [internal] => Array
  4. (
  5. [0] => zend_version
  6. [1] => func_num_args
  7. [2] => func_get_arg
  8. [3] => func_get_args
  9. [4] => strlen
  10. [5] => strcmp
  11. [6] => strncmp
  12. ...
  13. [750] => bcscale
  14. [751] => bccomp
  15. )
  16. [user] => Array
  17. (
  18. [0] => myrow
  19. )
  20. )

$ Arr ["internal"] is a built-in function, and $ arr ["user"] is a user-defined function.

PHP check function availability 4. check whether the specified function exists-function_exists

This function returns whether the specified function has been defined.

Usage:

 
 
  1. if (function_exists('imap_open')) {
  2. echo "IMAP functions are available.
    n";
  3. } else {
  4. echo "IMAP functions are not available.
    n";

PHP checks whether the function is available. 1. obtain all available modules-get_loaded_extensions. This function returns all loaded (available) modules. Usage: print_r (get_loade...

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.