5.x module.inc module_exists($module)
6.x module.inc module_exists($module)
7.x module.inc module_exists($module)

Determine whether a given module exists.


$module: The name of the module (without the .module extension).

Return value

TRUE if the module is both installed and enabled.

6 calls to module_exists()
block_admin_display_form in modules/block/block.admin.inc
Generate main blocks administration form.
node_admin_nodes in modules/node/node.admin.inc
Form builder: Builds the node administration overview.
path_admin_overview in modules/path/path.admin.inc
Return a listing of all defined URL aliases. When filter key passed, perform a standard search on the given key, and return the list of matching URL aliases.
system_admin_by_module in modules/system/system.admin.inc
Menu callback; prints a listing of admin tasks for each installed module.
template_preprocess_block_admin_display_form in modules/block/block.admin.inc
Process variables for block-admin-display.tpl.php.

... See full list


includes/module.inc, line 243
API for loading and interacting with Drupal modules.


function module_exists($module) {
  $list = module_list();
  return array_key_exists($module, $list);


davidshaw’s picture

Another similar check which can be helpful is PHP's own function_exists()
Check its documentation here:

Dave Shaw
Tribe Rising

marty’s picture

Is this the best practice in the case where I am writing a new module with a function that will be used by an existing module?

eg. in the existing module code

if(module_exists(new_module)) {
// call function in new_module