" and save the file and upload it to the server. Access the info.php file in the browser and find "Loaded Extensions" to query."/> " and save the file and upload it to the server. Access the info.php file in the browser and find "Loaded Extensions" to query.">

Home >Backend Development >PHP Problem >How to check which extensions are installed in php

How to check which extensions are installed in php

zbt
zbtOriginal
2023-08-01 15:32:563728browse

You can check which extensions are installed in PHP through the command line, through the phpinfo() function and by checking the php.ini file. 1. Through the command line, use the "-m" option of the php command to query the installed extensions; 2. Through the phpinfo() function, create a file named info.php and enter "phpinfo();? >" and save the file and upload it to the server. Access the info.php file in the browser and find "Loaded Extensions" to query.

How to check which extensions are installed in php

The operating environment of this tutorial: windows10 system, php8.1.3 version, DELL G3 computer.

When using PHP to develop a website or application, we usually install some extensions to enhance the functionality and performance of PHP. However, it can get confusing when we need to determine which extensions are installed in the current PHP environment. Fortunately, PHP provides several methods to query installed extensions. This article will introduce three common methods: through the command line, through the phpinfo() function, and by checking the php.ini file.

1. Through the command line

Under the command line, we can use the "-m" option of the php command to query the installed extensions. Open a command line terminal, enter the following command and press Enter:

php -m

This will display all extensions installed in the current PHP environment.

2. Through the phpinfo() function

Another simple method is to use the phpinfo() function. Create a file called info.php and enter the following code in the file:

phpinfo();
?>

Save the file and upload it to your server. Then access the info.php file in your browser, and you will see a page with detailed information about the PHP environment. In this page, you can find "Loaded Extensions" (loaded extensions) section, which lists all extensions that have been installed.

3. Check the php.ini file

In some cases Next, we can also determine the installed extensions by checking the php.ini file. First, find the location of the php.ini file. Enter the following command in the command line terminal:

php --ini

This will display the current PHP environment The location of the php.ini file to use. Open the file and find the configuration related to the extension. In the php.ini file, the installed extensions will be listed and set to "extension=" line at the beginning.

The above are three common methods for querying installed PHP extensions. Each method is simple, and you can choose the method that suits you according to your actual needs to query installed extensions.

To summarize, understanding installed PHP extensions is very important for developing and maintaining PHP applications. Through the command line, the phpinfo() function, and checking the php.ini file, you can easily and quickly obtain a list of installed extensions to better understand and manage your PHP environment.

The above is the detailed content of How to check which extensions are installed in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn