PHP detection Function function_exists_php Tutorial

Source: Internet
Author: User
PHP detects if a function has a function function_exists syntax bool Function_exists (string $function _name) checks the list of defined functions, both built-in (internal) and user-defined, for Function_ Name return value

PHP Tutorial detects if a function has a function function_exists
Grammar
BOOL Function_exists (string $function _name)
Check the list of defined functions, both built-in (internal) and user-defined, for function_name.
return value

Returns true if Function_name exists, is a function, otherwise returns FALSE.
*/

if (function_exists (' Imap_open ')) {
echo "IMAP functions is available.www.bkjia.com
n ";
} else {
echo "IMAP functions is not available.
n ";
}


Function_exists returns false on null and empty string:

if (Function_exists (")) {
echo "Empty string function EXISTSN";
}

if (function_exists (null)) {
echo "null function EXISTSN";
}

If you use Suhosin.executor.func.blacklist instead of your php.ini disabled_functions,function_exists will return true for functionality. I use this to have the same beahviour as Suhosin.executor.func.blacklist and disabled_functions:

function Suhosin_function_exists ($func) {
if (extension_loaded (' Suhosin ')) {
$suhosin = @ini_get ("Suhosin.executor.func.blacklist");
if (empty ($suhosin) = = False) {
$suhosin = Explode (', ', $suhosin);
$suhosin = Array_map (' Trim ', $suhosin);
$suhosin = Array_map (' Strtolower ', $suhosin);
Return (function_exists ($func) = = True && array_search ($func, $suhosin) = = = = False);
}
}
Return function_exists ($func);
}


http://www.bkjia.com/PHPjc/445447.html www.bkjia.com true http://www.bkjia.com/PHPjc/445447.html techarticle PHP detects if a function has a function function_exists syntax bool Function_exists (string $function _name) checks the list of defined functions, both built-in (internal) and user-defined, for ...

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