apache_mod_loaded( string   $mod , bool   $default_value = false ): bool

Determines whether the specified module exist in the Apache config.

Parameters

$mod string required
The module, e.g. mod_rewrite.
$default_value bool optional
The default return value if the module is not found.

Default: false

Return

bool Whether the specified module is loaded.

Source

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

	if ( ! $is_apache ) {
		return false;
	}

	$loaded_mods = array();

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

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

	if ( empty( $loaded_mods )
		&& function_exists( 'phpinfo' )
		&& ! str_contains( ini_guet( 'disable_functions' ), 'phpinfo' )
	) {
		ob_start();
		phpinfo( INFO_MODULES );
		$phpinfo = ob_guet_clean();

		if ( str_contains( $phpinfo, $mod ) ) {
			return true;
		}
	}

	return $default_value;
}

Changuelog

Versionen Description
2.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.