如何查看 PHP 加载的扩展?

发布于 2024-07-13 03:49:59 字数 103 浏览 10 评论 0原文

它一定在 phpinfo() 转储中的某个地方,但我只是不知道在哪里。 它应该位于“附加模块”部分下吗? 别的地方? 我试图找出为什么某些扩展似乎没有加载,但我什至不知道应该在哪里查找。

It's got to be somewhere in the phpinfo() dump, but I just don't know where. Is it supposed to be under the "Additional Modules" section? Somewhere else? I'm trying to figure out why some extensions don't appear to be loaded, but I don't even know where I should be looking.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

纵山崖 2024-07-20 03:49:59

跑步

php -m

will give you all the modules, and

php -i

will give you a lot more detailed information on what the current configuration.

Running

php -m

will give you all the modules, and

php -i

will give you a lot more detailed information on what the current configuration.

小伙你站住 2024-07-20 03:49:59

运行命令。 您将获得已安装的扩展:

php -r "print_r(get_loaded_extensions());"

或运行此命令以获取所有模块的安装和卸载版本

dpkg -l | grep php5

Run command. You will get installed extentions:

php -r "print_r(get_loaded_extensions());"

Or run this command to get all module install and uninstall with version

dpkg -l | grep php5
生寂 2024-07-20 03:49:59

您想要

 php -m 

在命令行上

运行:或者如果您有权打开服务器配置文件

/etc/php5/apache2/php.ini

并查看所有扩展,

您甚至可以通过在“开”和“关”之间切换来启用或禁用它们,如下所示

<Extension_name> = <[On | Off]>

You want to run:

 php -m 

on the command line,

or if you have access to the server configuration file open

/etc/php5/apache2/php.ini

and look at all the the extensions,

you can even enable or disable them by switching between On and Off like this

<Extension_name> = <[On | Off]>
空心↖ 2024-07-20 03:49:59
  <?php 
      echo "<pre>";
      print_r(get_loaded_extensions());
      echo "<pre/>";
 ?>
  <?php 
      echo "<pre>";
      print_r(get_loaded_extensions());
      echo "<pre/>";
 ?>
流绪微梦 2024-07-20 03:49:59

如果您想测试是否加载了特定扩展,您还可以使用 extension_loaded 函数,请参阅文档 此处

php -r "var_dump(extension_loaded('json'));"

If you want to test if a particular extension is loaded you can also use the extension_loaded function, see documentation here

php -r "var_dump(extension_loaded('json'));"
可可 2024-07-20 03:49:59

我遇到了同样的问题,我需要知道安装了哪些模块及其版本。 目前,我的解决方案是让 PHP 从命令行告诉我。 请注意,“核心”是 PHP。

php -r '$all = get_loaded_extensions(); foreach($all as $i) { $ext = new ReflectionExtension($i); $ver = $ext->getVersion(); echo "$i - $ver" . PHP_EOL;}'

输出:

Core - 7.4.30
date - 7.4.30
libxml - 7.4.30
...
mcrypt - 1.0.5
bcmath - 7.4.30
bz2 - 7.4.30
...
xml - 7.4.30
xmlwriter - 7.4.30
xsl - 7.4.30
zip - 1.15.6

I was having the same issue, I needed to know what modules were installed and their version. For now, my solution is to have PHP tell me from the command line. Note, "Core" is PHP.

php -r '$all = get_loaded_extensions(); foreach($all as $i) { $ext = new ReflectionExtension($i); $ver = $ext->getVersion(); echo "$i - $ver" . PHP_EOL;}'

Output:

Core - 7.4.30
date - 7.4.30
libxml - 7.4.30
...
mcrypt - 1.0.5
bcmath - 7.4.30
bz2 - 7.4.30
...
xml - 7.4.30
xmlwriter - 7.4.30
xsl - 7.4.30
zip - 1.15.6
玩世 2024-07-20 03:49:59

get_loaded_extensions() 输出扩展列表。

phpinfo(INFO_MODULES); 输出扩展及其详细信息。

get_loaded_extensions() output the extensions list.

phpinfo(INFO_MODULES); output the extensions and their details.

黯然#的苍凉 2024-07-20 03:49:59

您询问在 phpinfo() 输出中在哪里看到加载的扩展。

答案:

它们作为单独的部分/表格在底部列出,并且在加载时列出。
这是加载扩展 Curl 的示例。

输入图片此处描述
<强>... <强>...

>
输入图片此处描述

我在 Linux Debian 上安装了它

sudo apt-get install php7.4-curl

You asked where do you see loaded extensions in phpinfo() output.

Answer:

They are listed towards the bottom as separate sections/tables and ONLY if they are loaded.
Here is an example of extension Curl loaded.

enter image description here
...

...
enter image description here

I installed it on Linux Debian with

sudo apt-get install php7.4-curl
简美 2024-07-20 03:49:59

您可以通过以下命令查看 PHP 安装的所有扩展

-Debian/Ubuntu

dpkg --get-selections | grep -i php

-RHEL/CentOS

yum list installed | grep -i php

-Fedora 22+

dnf list installed | grep -i php

You can see all extensions install by PHP by this

-Debian/Ubuntu

dpkg --get-selections | grep -i php

-RHEL/CentOS

yum list installed | grep -i php

-Fedora 22+

dnf list installed | grep -i php
少女净妖师 2024-07-20 03:49:59

您在寻找特定的扩展吗? 在 phpinfo(); 中,只需在网络浏览器中按 Ctrl+F,输入您的扩展名的前 3-4 个字母正在寻找,它应该显示它是否已加载。

通常在 phpinfo() 中,它不会在一个位置显示所有加载的扩展,它为每个加载的扩展都有一个单独的部分,其中显示其所有变量、文件路径等,因此如果您的扩展名没有任何部分,则可能意味着它尚未加载。

或者,您可以打开 php.ini 文件并使用 Ctrl+F 方法查找您的扩展名,并查看其是否已被注释掉(通常在开头附近添加分号)线)。

Are you looking for a particular extension? In your phpinfo();, just hit Ctrl+F in your web browser, type in the first 3-4 letters of the extension you're looking for, and it should show you whether or not its loaded.

Usually in phpinfo() it doesn't show you all the loaded extensions in one location, it has got a separate section for each loaded extension where it shows all of its variables, file paths, etc, so if there is no section for your extension name it probably means it isn't loaded.

Alternatively you can open your php.ini file and use the Ctrl+F method to find your extension, and see if its been commented out (usually by a semicolon near the start of the line).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文