The extension_loaded Function
The extension_loaded
function checks whether the specified extension is loaded in the current PHP configuration.
The function takes a string with the extension name as a parameter and returns true
if the extension is active,
or false
if it is not loaded.
Syntax
extension_loaded(string $extension): bool
Example
Let's check if the "json"
extension is loaded:
<?php
$res = extension_loaded('json');
var_dump($res);
?>
Code execution result:
true
Example
Let's check the availability of the "gd"
extension:
<?php
if (extension_loaded('gd')) {
echo 'GD extension is loaded';
} else {
echo 'GD extension is NOT loaded';
}
?>
Code execution result:
'GD extension is loaded'
See Also
-
the
get_loaded_extensions
function,
which returns a list of all loaded extensions -
the
function_exists
function,
which checks for the existence of a function