如何从CLI中查找php中内置模块的版本号

时间:2022-08-15 07:01:59

Basically i am new to php, and i just installed php on my machine. so we can know entire information of the php configuration by creating a php file and writing the below code in it

基本上我是php的新手,我刚刚在我的机器上安装了php。所以我们可以通过创建一个php文件并在其中编写下面的代码来了解php配置的全部信息

<?php 
  phpinfo();
?>

And i opened this through browser and can able to see all the configuration information

我通过浏览器打开它,可以看到所有的配置信息

But is there any way to know the version of php default modules from linux terminal(I am using fedora by the way :) )

但是有没有办法从linux终端知道php默认模块的版本(顺便说一下我使用fedora :))

So what all i mean to ask is whether is there any way to find the version number of all the modules or individual modules from terminal through some php commands ?

所以我要问的是,是否有任何方法可以通过一些php命令从终端找到所有模块或单个模块的版本号?

For example there is a command php -me which displays all the php modules that comes by default when php is installed like below

例如,有一个命令php -me,它显示了安装php时默认出现的所有php模块,如下所示

[PHP modules]
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
shmop
....
.....

but in the same way i want to find the version number of the individual module too from the terminal, how can we find it ?

但同样地,我想从终端找到单个模块的版本号,我们怎样才能找到它?

3 个解决方案

#1


20  

To see the version for one particular module, you can use php -ri <module> | grep Version.

要查看某个特定模块的版本,可以使用php -ri | grep版本。

For example:

php --ri mongo | grep Version

php --ri mongo | grep版本

Returns:

Version => 1.6.5

#2


18  

This should do the trick:

这应该是诀窍:

php -r 'foreach (get_loaded_extensions() as $extension) echo "$extension: " . phpversion($extension) . "\n";'

More readable version (for code usage):

更易读的版本(代码用法):

$extensions = get_loaded_extensions();
foreach ($extensions as $extension) {
    echo "$extension: " . phpversion($extension) . "\n";
}

#3


1  

you want the phpversion() command if you want to do it inscript http://php.net/manual/en/function.phpversion.php

你想要phpversion()命令,如果你想做它inscript http://php.net/manual/en/function.phpversion.php

#1


20  

To see the version for one particular module, you can use php -ri <module> | grep Version.

要查看某个特定模块的版本,可以使用php -ri | grep版本。

For example:

php --ri mongo | grep Version

php --ri mongo | grep版本

Returns:

Version => 1.6.5

#2


18  

This should do the trick:

这应该是诀窍:

php -r 'foreach (get_loaded_extensions() as $extension) echo "$extension: " . phpversion($extension) . "\n";'

More readable version (for code usage):

更易读的版本(代码用法):

$extensions = get_loaded_extensions();
foreach ($extensions as $extension) {
    echo "$extension: " . phpversion($extension) . "\n";
}

#3


1  

you want the phpversion() command if you want to do it inscript http://php.net/manual/en/function.phpversion.php

你想要phpversion()命令,如果你想做它inscript http://php.net/manual/en/function.phpversion.php