apache_mod_loaded

函数


apache_mod_loaded ( $mod, $default = false )
参数
  • (string)
    $mod
    The module, e.g. mod_rewrite.
    Required:
  • (bool)
    $default
    Optional. The default return value if the module is not found. Default false.
    Required:
    Default: false
返回值
  • (bool) Whether the specified module is loaded.
定义位置
  • wp-includes/functions.php
    , line 5891
引入
2.5.0
弃用

判断Apache配置中是否存在指定的模块。

function apache_mod_loaded( $mod, $default = false ) {
	global $is_apache;

	if ( ! $is_apache ) {
		return false;
	}

	$loaded_mods = array();

	if ( function_exists( 'apache_get_modules' ) ) {
		$loaded_mods = apache_get_modules();

		if ( in_array( $mod, $loaded_mods, true ) ) {
			return true;
		}
	}

	if ( empty( $loaded_mods )
		&& function_exists( 'phpinfo' )
		&& false === strpos( ini_get( 'disable_functions' ), 'phpinfo' )
	) {
		ob_start();
		phpinfo( INFO_MODULES );
		$phpinfo = ob_get_clean();

		if ( false !== strpos( $phpinfo, $mod ) ) {
			return true;
		}
	}

	return $default;
}