[PHP 4, PHP 5, PHP 7, PHP 8]
extension_loaded — Find out whether an extension is loaded
Description
extension_loaded[string $extension
]: bool
Parameters
extension
The extension name. This parameter is case-insensitive.
You can see the names of various extensions by using phpinfo[] or if you're using the CGI
or CLI
version of PHP you can use the -m switch to list all available extensions:
$ php -m [PHP Modules] xml tokenizer standard sockets session posix pcre overload mysql mbstring ctype [Zend Modules]
Return Values
Returns
true
if the extension identified by extension
is loaded, false
otherwise.
Examples
Example #1 extension_loaded[] example
See Also
- get_loaded_extensions[] - Returns an array with the names of all modules compiled and loaded
- get_extension_funcs[] - Returns an array with the names of the functions of a module
- phpinfo[] - Outputs information about PHP's configuration
- dl[] - Loads a PHP extension at runtime
- function_exists[] - Return true if the given function has been defined
There are no user contributed notes for this page.
[PHP 4, PHP 5, PHP 7, PHP 8]
get_loaded_extensions — Returns an array with the names of all modules compiled and loaded
Description
get_loaded_extensions[bool $zend_extensions
= false
]: array
Parameters
zend_extensions
Only return Zend extensions, if not then regular extensions, like mysqli are listed. Defaults to false
[return regular extensions].
Return Values
Returns an indexed array of all the modules names.
Examples
Example #1 get_loaded_extensions[] Example
The above example will output something similar to:
Array [ [0] => xml [1] => wddx [2] => standard [3] => session [4] => posix [5] => pgsql [6] => pcre [7] => gd [8] => ftp [9] => db [10] => calendar [11] => bcmath ]
See Also
- get_extension_funcs[] - Returns an array with the names of the functions of a module
- extension_loaded[] - Find out whether an extension is loaded
- dl[] - Loads a PHP extension at runtime
- phpinfo[] - Outputs information about PHP's configuration
There are no user contributed notes for this page.
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.
lospejos
1,9683 gold badges19 silver badges33 bronze badges
asked Jan 26, 2009 at 4:32
Running
php -m
will give you all the modules, and
php -i
will give you a lot more detailed information on what the current configuration.
answered Jan 26, 2009 at 5:47
Abdullah JibalyAbdullah Jibaly
50.9k40 gold badges121 silver badges196 bronze badges
0
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
answered Sep 1, 2015 at 5:18
1
answered Jan 26, 2009 at 19:46
troelskntroelskn
112k24 gold badges131 silver badges154 bronze badges
2
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
=
answered Nov 26, 2014 at 16:33
william.eyidiwilliam.eyidi
2,2754 gold badges26 silver badges34 bronze badges
answered Jun 3, 2016 at 11:31
Rahul YadavRahul Yadav
7178 silver badges11 bronze badges
3
If you want to test if a particular extension is
loaded you can also use the extension_loaded
function, see documentation here
php -r "var_dump[extension_loaded['json']];"
answered Oct 25, 2019 at 8:27
Elie FaësElie Faës
3,0751 gold badge24 silver badges39 bronze badges
1
get_loaded_extensions[]
output the extensions list.
phpinfo[INFO_MODULES];
output the extensions and their details.
answered Mar 23, 2016 at 4:12
jayxhjjayxhj
2,46418 silver badges23 bronze badges
Are you looking for a particular extension? In your phpinfo[];
, just hit
Ctrl+F in 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.
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.
Alternatively you can open your php.ini file and use the Ctrl+F method to find your extension, and see if its been commented out [usually by a semicolon near the start of the line].
answered Jan 26, 2009 at 5:53
AliAli
253k261 gold badges567 silver badges753 bronze badges
You asked where do you see loaded extensions in phpinfo[] output.
Answer:
They are listed towards the bottom as separate sections/tables and ONLY if they are loaded. Here is an example of extension Curl loaded.
...
I installed it on Linux Debian with
sudo apt-get install php7.4-curl
answered Mar 29, 2020 at 22:21
MeryanMeryan
1,02011 silver badges20 bronze badges
You can see all extensions install by PHP by this
-Debian/Ubuntu
dpkg --get-selections | grep -i php
-RHEL/CentOS
yum list installed | grep -i php
-Fedora 22+
dnf list installed | grep -i php
Tyler2P
2,24115 gold badges19 silver badges28 bronze badges
answered Feb 9 at 13:42
I was having the same issue, I needed to know what modules were installed and their version. For now, my solution is to have PHP tell me from the command line. Note, "Core" is PHP.
php -r '$all = get_loaded_extensions[]; foreach[$all as $i] { $ext = new ReflectionExtension[$i]; $ver = $ext->getVersion[]; echo "$i - $ver" . PHP_EOL;}'
Output:
Core - 7.4.30
date - 7.4.30
libxml - 7.4.30
...
mcrypt - 1.0.5
bcmath - 7.4.30
bz2 - 7.4.30
...
xml - 7.4.30
xmlwriter - 7.4.30
xsl - 7.4.30
zip - 1.15.6
answered Aug 31 at 15:23
MikeGMikeG
1241 silver badge10 bronze badges