Check php extension is installed and available or not using php function

Here i have written simple php function by which you can test php extension installed and available or not.

For example if you need to check whether curl is installed and available in a web server, you can use function below to check the same. just pass the extension name and function will return true or false.

<?php
function isExtAvailable($extName)
{
    if  (in_array  ($extName, get_loaded_extensions())) {
        return true;
    }
    else{
        return false;
    }
}
?>




Now call this function and pass the extension name which you have to check the availability

<?php
$extName = 'curl'
echo (iscurlinstalled($extName)) ? $extName.' found' : $extName.' not available';
?>
Posted in: PHP

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.