apache_mod_loaded

Does the specified module exist in the Apache config?.

Description

apache_mod_loaded( (string) $mod, (constant) $default = false ); 

Parameters (2)

0. $mod (string)
The module, e.g. mod_rewrite.
1. $default — Optional. (constant) => false
The default return value if the module is not found. Default false.

Usage

  1. if ( !function_exists( 'apache_mod_loaded' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // The module, e.g. mod_rewrite. 
  5. $mod = ''; 
  6.  
  7. // Optional. The default return value if the module is not found. Default false. 
  8. $default = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = apache_mod_loaded($mod, $default); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function apache_mod_loaded($mod, $default = false) { 
  2. global $is_apache; 
  3.  
  4. if ( !$is_apache ) 
  5. return false; 
  6.  
  7. if ( function_exists( 'apache_get_modules' ) ) { 
  8. $mods = apache_get_modules(); 
  9. if ( in_array($mod, $mods) ) 
  10. return true; 
  11. } elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) { 
  12. ob_start(); 
  13. phpinfo(8); 
  14. $phpinfo = ob_get_clean(); 
  15. if ( false !== strpos($phpinfo, $mod) ) 
  16. return true; 
  17. return $default;