简体   繁体   English

PHP扩展安装与启用

[英]php extension installed vs enabled

I was running through a situation when i am unable to find if extension enabled and extension installed . 我在无法找到是否启用 扩展安装 扩展的情况下遇到了麻烦。 I googled it did not get a direct answer. 我用谷歌搜索没有得到直接的答案。

I have two questions- 我有两个问题-

que1 - que1-

How to check if an extension is installed ? 如何检查是否安装了扩展程序?

que2 - que2-

How to check if that extension is installed then is it enabled or not? 如何检查该扩展程序是否已安装,是否已启用?

I have found bunch of php functions like get_loaded_extensions , extension_loaded , function_exixts which i found has been used, but what is the exact difference between using each one of them? 我发现一堆使用过的php函数,例如get_loaded_extensionsextension_loadedfunction_exixts ,但是使用它们中的每一个之间的确切区别是什么?

Any help would be appreciated :) Thanks 任何帮助,将不胜感激:)谢谢

To check whether an extension is installed you should use the get_loaded_extensions() to get a list of all extensions that are installed. 要检查是否安装了扩展,您应该使用get_loaded_extensions()获取所有已安装扩展的列表。 In order to check whether a specific extension is installed you could use extension_loaded . 为了检查是否安装了特定的扩展,可以使用extension_loaded To check whether functions exist or not (function that come with the extension for example) you should use function_exixts . 要检查功能是否存在(例如,扩展附带的功能),应使用function_exixts

Another possibility to check whether an extension is installed is by looking at your phpinfo() and browse for the extension you are looking for. 检查是否已安装扩展的另一种可能性是通过查看phpinfo()并浏览所需的扩展。

At the command line you could run php -m and then to get you all the modules and then php -i to see more about the configuration of it. 在命令行中,您可以运行php -m ,然后获取所有模块,然后运行php -i以了解有关其配置的更多信息。

When you know the extension is installed you could enable it by looking at the php.ini file and search for extension=extensionname.so (when using Unix). 当您知道扩展已安装时,可以通过查看php.ini文件并搜索extension=extensionname.so (使用Unix)来启用它。 when using Windows look for extension=extensionname.dll . 使用Windows时,请查找extension=extensionname.dll When you cannot find this you will need to add it to the list with others that do exist. 如果找不到,则需要将其与其他存在的列表一起添加到列表中。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM