How to see the extensions loaded by PHP ?


There are multiple ways to see the extensions loaded by PHP:

  • Using phpinfo() function:
  • Create a PHP file with the following code:
   <?php
   phpinfo();
   ?>
  • Run the file on your server and it will display a lot of information about your PHP installation including the loaded extensions.

  • Using the command line interface:

  • Open your terminal or command prompt.
  • Type the following command and hit enter:
   php -m
  • This will display a list of all the loaded extensions.

  • Using the ini file:

  • Open your php.ini file.
  • Look for the line that starts with "extension=".
  • All the extensions that are loaded will be listed after this line.

Example: Let's say you want to check if the "mysqli" extension is loaded or not. You can use any of the above methods to check it. Here's an example using the command line interface:

  • Open your terminal or command prompt.
  • Type the following command and hit enter:
   php -m | grep mysqli
  • If the "mysqli" extension is loaded, it will display "mysqli" in the output. If it's not loaded, there will be no output.


About the author

William Pham is the Admin and primary author of Howto-Code.com. With over 10 years of experience in programming. William Pham is fluent in several programming languages, including Python, PHP, JavaScript, Java, C++.