apache_get_modules

(PHP 4 >= 4.3.2, PHP 5)

apache_get_modulesВозвращает список загруженных модулей сервера Apache

Описание

array apache_get_modules ( void )

Возвращает список загруженных модулей сервера Apache.

Возвращаемые значения

Массив загруженных модулей сервера Apache.

Список изменений

Версия Описание
5.0.0 Функция стала доступна при использовании Apache 1, или PHP Apache 2 filter API. Ранее это было возможно только c Apache 2 handler API.

Примеры

Пример #1 Пример использования apache_get_modules()

<?php
print_r
(apache_get_modules());
?>

Результатом выполнения данного примера будет что-то подобное:

Array
(
    [0] => core
    [1] => http_core
    [2] => mod_so
    [3] => sapi_apache2
    [4] => mod_mime
    [5] => mod_rewrite
)

Коментарии

this function can be used on older php versions using something like "/etc/httpd/httpd.conf" as $fname

<?php

function get_modules ($fname){
   if (
is_readable($fname)){
     
$fcont file($fname);
      if (
is_array($fcont)){
          foreach (
$fcont as $line){
              if (
preg_match ("/^LoadModule\s*(\S*)\s*(\S*)/i",$line,$match)){
                 
$return[$match[2]] = $match[1];
              }
          }
      }
   }
   return 
$return;
}

?>
2005-08-04 05:13:56
http://php5.kiev.ua/manual/ru/function.apache-get-modules.html
<?php
function apache_module_exists($module_name)
{
   
$modules apache_get_modules();
    foreach (
$modules as $module)
    {
        if (
$module == $module_name)
            return 
true;
    }
   
    return 
false;
}
var_dump(apache_module_exists('mod_headers'));
2013-07-29 04:56:30
http://php5.kiev.ua/manual/ru/function.apache-get-modules.html
Автор:
function apache_module_exists($module_name)
{
    $modules = apache_get_modules();
    return ( in_array($module_name, $modules) ? true : false );
}

var_dump(apache_module_exists('mod_headers'));
2013-09-03 15:07:24
http://php5.kiev.ua/manual/ru/function.apache-get-modules.html
Автор:
<?php
function apache_module_exists($module)
{
    return 
in_array($moduleapache_get_modules());
}
?>
2013-11-29 12:19:32
http://php5.kiev.ua/manual/ru/function.apache-get-modules.html
apache_get_modules() is only available when the PHP is installed as a module and not as a CGI == It doesn't work with php-fpm.
2020-07-28 06:35:49
http://php5.kiev.ua/manual/ru/function.apache-get-modules.html
/** 
 * Check if a Apache module is loaded (even if php run as fcgi or cgi )
 * 
 * @param string $module 
 * @return bool 
 */
public static function apache_check_module(string $module): bool
{
    $module  = ($module ? strval(value: $module) : '');
    if (function_exists('apache_get_modules')  && !empty($module)) {
        if (in_array(needle: $module, haystack: apache_get_modules())) {
            return TRUE;
        }
    } else if (!empty(shell_exec(command: 'apache2ctl -M | grep \'' . $module . '\''))) {
        return TRUE;
    } else {
        return FALSE;
    }
}
2024-01-18 16:51:44
http://php5.kiev.ua/manual/ru/function.apache-get-modules.html

    Поддержать сайт на родительском проекте КГБ