407 of 410 menu

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

byenru