The get_loaded_extensions() is an inbuilt function that returns an array of loaded and compiled modules in PHP.
Syntax:
get_loaded_extensions(bool $zend_extensions = false):
Parameters: This function has only one parameter.
- $zend_extensions: It only returns zend extensions, if not then regular extensions, like MySQLi are listed. It defaults to “false” (return regular extensions).
Return Values:
- This function returns an associative array of all loaded functions with an index.
Example 1: The following code snippet demonstrates the get_loaded_extensions() function.
PHP
<?php print_r(get_loaded_extensions()); ?> |
Output:
Array
(
[0] => Core
[1] => date
[2] => libxml
[3] => openssl
[4] => pcre
[5] => zlib
[6] => filter
[7] => hash
[8] => json
[9] => pcntl
[10] => Reflection
[11] => SPL
[12] => session
[13] => standard
[14] => sodium
[15] => mysqlnd
[16] => PDO
[17] => calendar
[18] => ctype
[19] => exif
[20] => FFI
[21] => fileinfo
[22] => ftp
[23] => gettext
[24] => iconv
[25] => mysqli
[26] => pdo_mysql
[27] => Phar
[28] => posix
[29] => readline
[30] => shmop
[31] => sockets
[32] => sysvmsg
[33] => sysvsem
[34] => sysvshm
[35] => tokenizer
[36] => Zend OPcache
)
Example 2: The following code snippet demonstrates the get_loaded_extensions() function.
PHP
<?php print_r(get_loaded_extensions(true)); ?> |
Output:
Array ( [0] => Zend OPcache )
Reference: https://www.php.net/manual/en/function.get-loaded-extensions.php