HomeCoding & Programming

Check whether a PHP extension is loaded or not

Like Tweet Pin it Share Share Email

How to figure out whether PHP extension is loaded or not on your page?

 

Usually in phpinfo() 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.

 

You can also check by below PHP function, if you know the exact name of PHP extension.

 

<?php
//gd represented GD Library as you usual say
if (!extension_loaded('gd')) {
	if (!dl('gd.so')) {
		exit;
	}
}
?>

Returns Boolean value true if the extension loaded and false otherwise .

Some other PHP extension related functions are

 

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

 

dl()
Loads a PHP extension at runtime

 

Note: dl() is disables in some environment and it will also disabled in PHP Safe Mode.