Php посмотреть все расширения

phpinfo

Outputs a large amount of information about the current state of PHP. This includes information about PHP compilation options and extensions, the PHP version, server information and environment (if compiled as a module), the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License.

Because every system is setup differently, phpinfo() is commonly used to check configuration settings and for available predefined variables on a given system.

phpinfo() is also a valuable debugging tool as it contains all EGPCS (Environment, GET, POST, Cookie, Server) data.

Parameters

The output may be customized by passing one or more of the following constants bitwise values summed together in the optional flags parameter. One can also combine the respective constants or bitwise values together with the bitwise or operator.

phpinfo() options

Name (constant) Value Description
INFO_GENERAL 1 The configuration line, php.ini location, build date, Web Server, System and more.
INFO_CREDITS 2 PHP Credits. See also phpcredits() .
INFO_CONFIGURATION 4 Current Local and Master values for PHP directives. See also ini_get() .
INFO_MODULES 8 Loaded modules and their respective settings. See also get_loaded_extensions() .
INFO_ENVIRONMENT 16 Environment Variable information that’s also available in $_ENV .
INFO_VARIABLES 32 Shows all predefined variables from EGPCS (Environment, GET, POST, Cookie, Server).
INFO_LICENSE 64 PHP License information. See also the » license FAQ.
INFO_ALL -1 Shows all of the above.
Читайте также:  Css минимальный отступ слева

Return Values

Always returns true .

Examples

Example #1 phpinfo() Example

// Show all information, defaults to INFO_ALL
phpinfo ();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo ( INFO_MODULES );

Notes

Note:

In versions of PHP before 5.5, parts of the information displayed are disabled when the expose_php configuration setting is set to off . This includes the PHP and Zend logos, and the credits.

Note:

phpinfo() outputs plain text instead of HTML when using the CLI mode.

See Also

  • phpversion() — Gets the current PHP version
  • phpcredits() — Prints out the credits for PHP
  • ini_get() — Gets the value of a configuration option
  • ini_set() — Sets the value of a configuration option
  • get_loaded_extensions() — Returns an array with the names of all modules compiled and loaded
  • Predefined Variables

User Contributed Notes 21 notes

A simple method to style your own phpinfo() output.

ob_start () ;
phpinfo () ;
$pinfo = ob_get_contents () ;
ob_end_clean () ;

// the name attribute «module_Zend Optimizer» of an anker-tag is not xhtml valide, so replace it with «module_Zend_Optimizer»
echo ( str_replace ( «module_Zend Optimizer» , «module_Zend_Optimizer» , preg_replace ( ‘%^.*(.*).*$%ms’ , ‘$1’ , $pinfo ) ) ) ;

This is necessary to obtain a W3C validation (XHTML1.0 Transitionnal).
phpinfo’s output is declared with that DTD :
— «System ID» has the wrong url to validate : «DTD/xhtml1-transitional.dtd» rather than «http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd»
— Some module names contains space and the function’s output use the name in anchors as ID and NAME. these attributes can’t be validated like that (unique name only).

ob_start (); // Capturing
phpinfo (); // phpinfo ()
$info = trim ( ob_get_clean ()); // output

// Replace white space in ID and NAME attributes. if exists
$info = preg_replace ( ‘/(id|name)(=[«\’][^ «\’]+) ([^ «\’]*[«\’])/i’ , ‘$1$2_$3’ , $info );

$info_doc = new DOMDocument ( ‘1.0’ , ‘utf-8’ );
/* Parse phpinfo’s output
* operator @ used to avoid messages about undefined entities
* or use loadHTML instead
*/
@ $info_doc -> loadXML ( $info );

$doc -> documentElement -> appendChild ( // Adding HEAD element to HTML
$doc -> importNode (
$info_doc -> getElementsByTagName ( ‘head’ )-> item ( 0 ),
true // With all the subtree
)
);
$doc -> documentElement -> appendChild ( // Adding BODY element to HTML
$doc -> importNode (
$info_doc -> getElementsByTagName ( ‘body’ )-> item ( 0 ),
true // With all the subtree
)
);

// Now you get a clean output and you are able to validate.
/*
echo ($doc->saveXML ());
// OR
echo ($doc->saveHTML ());
*/

// By that way it’s easy to add some style declaration :
$style = $doc -> getElementsByTagName ( ‘style’ )-> item ( 0 );
$style -> appendChild (
$doc -> createTextNode (
‘/* SOME NEW CSS RULES TO ADD TO THE FUNCTION OUTPUT */’
)
);

// to add some more informations to display :
$body = $doc -> getElementsByTagName ( ‘body’ )-> item ( 0 );
$element = $doc -> createElement ( ‘p’ );
$element -> appendChild (
$doc -> createTextNode (
‘SOME NEW CONTENT TO DISPLAY’
)
);
$body -> appendChild ( $element );

// to add a new header :
$head = $doc -> getElementsByTagName ( ‘head’ )-> item ( 0 );
$meta = $doc -> createElement ( ‘meta’ );
$meta -> setAttribute ( ‘name’ , ‘author’ );
$meta -> setAttribute ( ‘content’ , ‘arimbourg at ariworld dot eu’ );
$head -> appendChild ( $meta );

// As you wish, take the rest of the output and add it for debugging
$out = ob_get_clean ();

$pre = $doc -> createElement ( ‘div’ ); // or pre
$pre -> setAttribute ( ‘style’ , ‘white-space: pre;’ ); // for a div element, useless with pre
$pre -> appendChild ( $doc -> createTextNode ( $out ));
$body -> appendChild ( $pre );

$doc -> formatOutput = true ; // For a nice indentation
$doc -> saveXML ();

?>

All that could be done with only RegExp but I prefer the use of DOM for manipulating documents

Источник

get_loaded_extensions

Функция возвращает массив имён всех скомпилированных и загруженных в интерпретаторе PHP модулей.

Список параметров

Возвращать только модули Zend или обычные модули, такие как mysqli. По умолчанию false (возврат обычных модулей).

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

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

Примеры

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

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

Array ( [0] => Core [1] => date [2] => libxml [3] => pcre [4] => sqlite3 [5] => zlib [6] => ctype [7] => dom [8] => fileinfo [9] => filter [10] => hash [11] => json [12] => mbstring [13] => SPL [14] => PDO [15] => session [16] => posix [17] => Reflection [18] => standard [19] => SimpleXML [20] => pdo_sqlite [21] => Phar [22] => tokenizer [23] => xml [24] => xmlreader [25] => xmlwriter [26] => gmp [27] => iconv [28] => intl [29] => bcmath [30] => sodium [31] => Zend OPcache )

Смотрите также

  • get_extension_funcs() — Возвращает массив имён функций модуля
  • extension_loaded() — Определяет, загружен ли модуль
  • dl() — Загружает модуль PHP во время выполнения
  • phpinfo() — Выводит информацию о текущей конфигурации PHP

User Contributed Notes

  • Опции PHP/информационные функции
    • assert_​options
    • assert
    • cli_​get_​process_​title
    • cli_​set_​process_​title
    • dl
    • extension_​loaded
    • gc_​collect_​cycles
    • gc_​disable
    • gc_​enable
    • gc_​enabled
    • gc_​mem_​caches
    • gc_​status
    • get_​cfg_​var
    • get_​current_​user
    • get_​defined_​constants
    • get_​extension_​funcs
    • get_​include_​path
    • get_​included_​files
    • get_​loaded_​extensions
    • get_​required_​files
    • get_​resources
    • getenv
    • getlastmod
    • getmygid
    • getmyinode
    • getmypid
    • getmyuid
    • getopt
    • getrusage
    • ini_​alter
    • ini_​get_​all
    • ini_​get
    • ini_​parse_​quantity
    • ini_​restore
    • ini_​set
    • memory_​get_​peak_​usage
    • memory_​get_​usage
    • memory_​reset_​peak_​usage
    • php_​ini_​loaded_​file
    • php_​ini_​scanned_​files
    • php_​sapi_​name
    • php_​uname
    • phpcredits
    • phpinfo
    • phpversion
    • putenv
    • set_​include_​path
    • set_​time_​limit
    • sys_​get_​temp_​dir
    • version_​compare
    • zend_​thread_​id
    • zend_​version
    • get_​magic_​quotes_​gpc
    • get_​magic_​quotes_​runtime
    • restore_​include_​path

    Источник

    Как посмотреть список установленных расширений php на сервере с консоли

    При написании программ на php иногда нужно узнать, установлено ли необходимое расширение этого языка на сервере. Есть несколько способов посмотреть список установленных расширений php на сервере. В этой статье разберём самый очевидный: Как посмотреть список установленных расширений php на сервере с консоли. Для этого потребуется ssh-доступ на сервер, который возможен с помощью программы PuTTY или любой другой, позволяющей удалённо работать с командной строкой сервера.

    Как посмотреть все имена доступных расширений php на сервере

    Для того, чтобы посмотреть, какие расширения php установлены на сервере, достаточно воспользоваться командой

    Это возможно при работе с CGI-версией или CLI-версией PHP.

    Отображение списка доступных расширений php с консоли

    После запуска этой команды, будет выведен список доступных расширений php. Например:

    root@:~# php -m [PHP Modules] bcmath bz2 calendar Core ctype curl date dba dom ereg exif fileinfo filter ftp gd gettext hash iconv json libxml mbstring mcrypt mhash mysql mysqli openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop SimpleXML soap sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter Zend OPcache zip zlib [Zend Modules] Zend OPcache

    Резюме

    Таким образом, имея ssh-доступ на сервер, можно быстро определить, установлено ли нужное расширение на сервере или нет, и его требуется установить для решения той задачи, которая требует для её решения определённого расширения.

    Заберите ссылку на статью к себе, чтобы потом легко её найти!
    Раз уж досюда дочитали, то может может есть желание рассказать об этом месте своим друзьям, знакомым и просто мимо проходящим?
    Не надо себя сдерживать! 😉

    Источник

    Список расширений PHP

    Список расширений PHP можно для любого веб-проекта посмотреть в выводе скрипта phpinfo. В котором приведены все подключенные расширения и настройки для них. phpinfo размещается в корне сайта.

    В статье о том, как посмотреть настройки PHP описано создание скрипта для вывода актуальных настроек. Это самый надежный способ.

    Как просмотреть список расширений PHP

    phpinfo покажет те расширения, которые фактически используются. Например, mysqli и mysqlnd, среди прочих:

    Список расширений PHP

    Расширения представляют собой файлы .so, они подключаются в файле php.ini. Какие-то расширения могут быть заданы при компиляции и в качестве отдельных файлов не подключаться.

    Файлы расширений, которые могут быть не подключены находятся, например, с помощью whereis.

    php7: /usr/bin/php7.2 /usr/bin/php7.1 /usr/bin/php7.0 /usr/lib/php7.2 /usr/lib/php7.1 /usr/lib/php7.0 /usr/bin/X11/php7.2 /usr/bin/X11/php7.1 /usr/bin/X11/php7.0

    В примере для версии PHP7.1.

    Вывод — все каталоги, как-либо относящиеся к мажорной версии (7). В обозначениях 7.0, 7.1 и 7.2 число после точки является минорной версией.

    Расширения следует искать в /usr/lib/php7.1

    total 16368 drwxr-xr-x 4 root root 4096 Oct 16 13:34 . drwxr-xr-x 55 root root 12288 Oct 16 13:30 .. drwxr-xr-x 2 root root 4096 Oct 16 13:34 20160303 drwxr-xr-x 2 root root 4096 Sep 10 13:09 build -rw-r--r-- 1 root root 381044 Sep 7 08:15 calendar.a -rw-r--r-- 1 root root 31288 Sep 7 08:16 calendar.so -rw-r--r-- 1 root root 73882 Sep 7 08:15 ctype.a -rw-r--r-- 1 root root 13936 Sep 7 08:16 ctype.so -rw-r--r-- 1 root root 583294 Sep 7 08:15 curl.a -rw-r--r-- 1 root root 81712 Sep 7 08:16 curl.so -rw-r--r-- 1 root root 418472 Sep 7 08:15 ftp.a -rw-r--r-- 1 root root 53200 Sep 7 08:16 ftp.so -rw-r--r-- 1 root root 2370310 Sep 7 08:15 gd.a -rw-r--r-- 1 root root 369240 Sep 7 08:16 gd.so .

    Все .so файлы можно подключать в php.ini. Если какие-то расширения скомпилированы вручную — они могут находиться в других каталогах, но в общем случае таковых нет.

    Источник

Оцените статью