drupal_function_exists

Definition

drupal_function_exists($function)
drupal/includes/bootstrap.inc, line 1419

Description

Confirm that a function is available.

If the function is already available, this function does nothing. If the function is not available, it tries to load the file where the function lives. If the file is not available, it returns false, so that it can be used as a drop-in replacement for function_exists().

Parameters

$function The name of the function to check or load.

Return value

TRUE if the function is now available, FALSE otherwise.

Related topics

Namesort iconDescription
Code registryThe code registry engine.

Code

function drupal_function_exists($function) {
  static $checked = array();

  if (defined('MAINTENANCE_MODE')) {
    return function_exists($function);
  }

  if (isset($checked[$function])) {
    return $checked[$function];
  }
  $checked[$function] = FALSE;

  if (function_exists($function)) {
    $checked[$function] = TRUE;
    return TRUE;
  }

  $checked[$function] = _registry_check_code('function', $function);

  return $checked[$function];
}