如何查看 PHP 加载的扩展?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/478844/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:52:59  来源:igfitidea点击:

How do I see the extensions loaded by PHP?

phpphp-extension

提问by Bialecki

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.

它必须在 phpinfo() 转储中的某个地方,但我只是不知道在哪里。它应该在“附加模块”部分下吗?别的地方?我想弄清楚为什么有些扩展似乎没有加载,但我什至不知道我应该去哪里找。

回答by Abdullah Jibaly

Running

跑步

php -m
会给你所有的模块,和
php -i
将为您提供有关当前配置的更多详细信息。

回答by Saurabh Chandra Patel

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

回答by troelskn

use get_loaded_extensions()PHP function

使用get_loaded_extensions()PHP 函数

回答by william.eyidi

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

您甚至可以通过像这样在 On 和 Off 之间切换来启用或禁用它们

<Extension_name> = <[On | Off]>

回答by Rahul Yadav

  <?php 
      echo "<pre>";
      print_r(get_loaded_extensions());
      echo "<pre/>";
 ?>

回答by jayxhj

get_loaded_extensions()output the extensions list.

get_loaded_extensions()输出扩展列表。

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

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

回答by PeterPan666

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

如果您想测试是否加载了特定扩展,您也可以使用该extension_loaded功能,请参阅此处的文档

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

回答by Click Upvote

Are you looking for a particular extension? In your phpinfo();, just hit Ctrl+Fin 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.

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

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.

通常phpinfo()它不会在一个位置显示所有加载的扩展,它为每个加载的扩展都有一个单独的部分,它显示了它的所有变量、文件路径等,所以如果你的扩展名没有部分可能意味着它没有加载。

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

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

回答by Meryan

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

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

Answer:

回答:

They are listed towards the bottom as separate sections/tables and ONLYif 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

我将它安装在 Linux Debian 上

sudo apt-get install php7.4-curl