Check php module version

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.

Return Values

Returns true on success or false on failure.

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
PHP 8.2

(PHP 7, 8) phpdbg_start_oplog This function currently not documented; only its argument list available.

(PHP 4, 5, 7, 8) phpversion Gets the current Returns a string containing the version of currently running PHP parser or extension.

Источник

phpversion

Возвращает строку,содержащую версию текущего парсера или расширения PHP.

Parameters

Дополнительное имя расширения.

Return Values

Возвращает текущую версию PHP в виде строки. Если для параметра extension указан строковый аргумент , phpversion () возвращает версию этого расширения или false , если информация о версии не связана или расширение не включено.

Changelog

Examples

Пример # 1 phpversion () Пример

 // prints e.g. 'Current PHP version: 4.1.1' echo 'Current PHP version: ' . phpversion(); // prints e.g. '2.0' or nothing if the extension isn't enabled echo phpversion('tidy'); ?>

Пример # 2 Пример и использование PHP_VERSION_ID

 // PHP_VERSION_ID is available as of PHP 5.2.7, if our // version is lower than that, then emulate it if (!defined('PHP_VERSION_ID')) < $version = explode('.', PHP_VERSION); define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2])); > // PHP_VERSION_ID is defined as a number, where the higher the number // is, the newer a PHP version is used. It's defined as used in the above // expression: // // $version_id = $major_version * 10000 + $minor_version * 100 + $release_version; // // Now with PHP_VERSION_ID we can check for features this PHP version // may have, this doesn't require to use version_compare() everytime // you check if the current PHP version may not support a feature. // // For example, we may here define the PHP_VERSION_* constants thats // not available in versions prior to 5.2.7 if (PHP_VERSION_ID < 50207) < define('PHP_MAJOR_VERSION', $version[0]); define('PHP_MINOR_VERSION', $version[1]); define('PHP_RELEASE_VERSION', $version[2]); // and so on, . > ?>

Notes

Note:

Эта информация также доступна в предопределенной константе PHP_VERSION . Дополнительная информация о PHP_VERSION_* доступна с использованием констант PHP_VERSION_ * .

See Also

  • PHP_VERSION constants
  • version_compare () — сравнивает две строки номеров версии, стандартизированные для PHP.
  • phpinfo () — выводит информацию о конфигурации PHP
  • phpcredits () — распечатывает кредиты для PHP
  • zend_version () — Получает версию текущего движка Zend
PHP 8.2

(PHP 7,8)phpdbg_start_oplog Эта функция в настоящее время не документирована;доступен только список ее аргументов.

(PHP 4, 5, 7, 8) phpinfo Выводит информацию о конфигурации PHP Выводит большое количество информации о текущем состоянии PHP.

(PHP 4 4.0.5,7)png2wbmp Преобразование файла изображения в Эта функция была ОТМЕНЕНА в PHP 7.2.0 и УДАЛЕНА в 8.0.0.

Источник

Как просмотреть список установленных модулей PHP в Linux

PHP — это популярный язык программирования, который позволяет быстро разрабатывать веб-сайты и веб-приложения. Он поддерживает огромное количество модулей и плагинов, которые вы можете включить в свою установку PHP, чтобы увеличить функциональность ваших сайтов. По мере добавления все новых и новых модулей в нашу установку PHP, мы можем потерять представление о том, какие модули доступны, а какие нет. В таких случаях, чтобы просто перечислить установленные модули PHP в Linux. В этой статье мы узнаем, как составить список установленных модулей PHP в Linux.

Как составить список установленных модулей PHP в Linux

Ниже описаны шаги для составления списка модулей PHP. Некоторые пакеты компилируются при установке PHP, другие устанавливаются после установки PHP. Мы узнаем, как получить список модулей обоих типов.

Как вывести список скомпилированных модулей PHP

Если вы хотите просмотреть список всех скомпилированных модулей PHP, откройте терминал и выполните следующую команду.

список скомпилированных модулей PHP

Приведенная выше команда покажет все скомпилированные пакеты, которые могут быть довольно длинными. Если вы ищете конкретный скомпилированный пакет, просто передайте вывод вышеприведенной команды команде grep. Вот команда для поиска того, скомпилирован ли модуль ftp или нет.

В приведенной выше команде мы используем опцию -i в grep, чтобы игнорировать регистр имен модулей.

Как составить список установленных модулей PHP

Вы также можете установить модули через менеджеры пакетов Linux, такие как yum, dnf, dpkg.

RHEL, CentOS

Debian, Ubuntu

Приведенные выше команды выведут список всех модулей, которые вы установили с помощью менеджеров пакетов. Если вы ищете конкретный модуль, вы можете передать вывод вышеприведенной команды команде grep и найти нужный пакет. Вот команда для поиска модуля ftp в PHP.

yum list installed | grep -i php | grep -i ftp
dnf list installed | grep -i php | grep -i ftp
dpkg --get-selections | grep -i php | grep -i ftp

Использование PHPInfo

В качестве альтернативы вы можете создать небольшой PHP-файл и добавить его в корень вашего сайта, чтобы просмотреть список всех модулей в вашем веб-браузере. Этот файл называется phpinfo(). Создайте пустой файл test.php в корневом месте вашего сайта, где хранятся все остальные документы о вашем сайте. Вы можете использовать любое имя файла, лишь бы расширение было .php.

Добавьте в него следующие строки.

Избегайте использования index.php в качестве имени файла, так как он обычно обозначает домашнюю страницу, а также избегайте использования phpinfo.php, так как это облегчит хакерам поиск информации о вашей установке PHP.

Теперь вы можете напрямую просмотреть его в браузере, перейдя по URL http://your_domain_or_ip/test.php. Замените your_domain_or_ip на имя вашего домена или IP-адрес сервера. Эта веб-страница предоставит вам полную информацию о вашей установке PHP, такую как используемая версия PHP, доступные основные функции и загруженные модули.

Заключение

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

Похожие записи:

Источник

How to list compiled PHP Modules

Sometimes is useful to see what modules are compiled in your PHP installation.
Let’s see how we can check this both on the server/root level and on the user level.

1. On the server/root level
On the server level, you can use the command php -m

root@web [~]# php -m [PHP Modules] Core ctype curl date dom filter ftp gd hash iconv imap ionCube Loader json libxml mbstring mcrypt mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix readline Reflection session SimpleXML soap SPL sqlite3 standard tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl Zend OPcache zip zlib [Zend Modules] Zend OPcache the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) root@web [~]#

An improvement of the above command is to list the version of each module. We will use the command:

root@web [~]# php -r 'foreach (get_loaded_extensions() as $ext) echo "$ext : version " . phpversion($ext) . "\n";' Core : version 7.0.16 date : version 7.0.16 libxml : version 7.0.16 openssl : version 7.0.16 pcre : version 7.0.16 zlib : version 7.0.16 filter : version 7.0.16 hash : version 1.0 pcntl : version 7.0.16 readline : version 7.0.16 Reflection : version 7.0.16 SPL : version 7.0.16 session : version 7.0.16 standard : version 7.0.16 ctype : version 7.0.16 curl : version 7.0.16 dom : version 20031129 ftp : version 7.0.16 gd : version 7.0.16 iconv : version 7.0.16 imap : version 7.0.16 json : version 1.4.0 mbstring : version 7.0.16 mcrypt : version 7.0.16 mysqlnd : version mysqlnd 5.0.12-dev - 20150407 PDO : version 7.0.16 Phar : version 2.0.2 posix : version 7.0.16 SimpleXML : version 7.0.16 soap : version 7.0.16 sqlite3 : version 0.7-dev tokenizer : version 7.0.16 xml : version 7.0.16 xmlwriter : version 7.0.16 xsl : version 7.0.16 zip : version 1.13.5 mysqli : version 7.0.16 pdo_mysql : version 7.0.16 pdo_sqlite : version 7.0.16 wddx : version 7.0.16 xmlreader : version 7.0.16 xmlrpc : version 7.0.16 ionCube Loader : version Zend OPcache : version 7.0.16 root@web [~]#

2. How to check loaded extensions as a user
Create and run a PHP file with the following content:

foreach (get_loaded_extensions() as $ext) echo “$ext : vers ” . phpversion($ext) . “
”;
?>

You will get a list of installed extensions alongside with their versions. To check if a specific extension is loaded, use the PHP function extension_loaded().

More info at PHP.net for the functions get_loaded_extensions() and extension_loaded()

Источник

Checking what PHP version I’m running on Linux?

I’m running Centos 5 and I need to know what version of PHP I’m running, is there a command for this which I can run?

4 Answers 4

Try running the following at the command line.

To just get the version information:

It should give you all information you need about the php install.

Just be cautious that the CLI version of PHP (checked from command line) can be different from the one served by your webserver (shown by phpinfo())

@AkshayRaje Exactly. Most people who ask “What PHP version am I using?” are usually referring to the Apache/Nginx PHP module and not the PHP CLI stuff. The PHP CLI info has 100% nothing to do with the PHP module used by Apache/Nginx.

You can make an index.php file with

this has the advantage of working on servers you don’t have ssh access to, though personally I’ve always preferred , just for the futureproofing 😛

On any PHP website one can often see the version in the X-Powered-By header in each PHP generated HTTP response. When you don’t have SSH access, then sometimes phpshell.sourceforge.net can be used. (Though with much care, like one needs to check if a folder is writable before running a tar command.)

First, this is the answer. Most people who ask “What PHP version am I using?” are usually referring to the Apache/Nginx PHP module and not the PHP CLI stuff. The PHP CLI info has 100% nothing to do with the PHP module used by Apache/Nginx. But @Arjan also, many systems administrators disable the “X-Powered-By” header servers send out as part of security hardening. While it seems convenient for developers, headers like that put you on the “sucker list” for botnet attacks. If you run a server and the main way you are determining PHP version is via “X-Powered-By” your process is very flawed.

Источник

Читайте также:  Clearing all cookies with javascript
Оцените статью