2 Methods to Get All Loaded Extensions in PHP

2 Methods to Get All Loaded Extensions in PHP

PHP, a widely used server-side scripting language, provides a robust environment for web development. To enhance its functionality, PHP supports extensions - additional modules that add features and capabilities to the language. Obtaining a list of all loaded extensions in PHP can be useful for debugging, ensuring the availability of required extensions, or simply understanding the environment in which the PHP scripts are running. This tutorial provides 2 methods how to get all loaded extensions in PHP.

Method 1 - get_loaded_extensions function

The get_loaded_extensions function is a handy tool for obtaining a list of all currently loaded extensions. It returns an array containing the names of these extensions.


$ext = get_loaded_extensions();

Output example:

    [0] => Core
    [1] => bcmath
    [2] => calendar
    [3] => ctype
    [4] => date
    [37] => zip
    [38] => xdebug

Method 2 - command line

If the command line approach is preferred to check loaded extensions, the following command can be used:

php -m

Executing this command will display a list of all loaded extensions in the PHP environment. It provides a quick and straightforward way to inspect extensions without writing a dedicated PHP script.

Output example:

[PHP Modules]

[Zend Modules]

Leave a Comment

Cancel reply

Your email address will not be published.