Question

I was asking myself if it is possible to check php files for required extensions like php-gd or php-xml. I'd like to identify all prerequisites to run a certain script.

I hope anyone can help.

Thanks in advance.

Best regards, christian

Was it helpful?

Solution

You can use extension_loaded:

if(extension_loaded('gd'))
{
    echo 'GD Library found';
}

Alternatively, you can use get_loaded_extensions(), which will return an array.

OTHER TIPS

<?php
    if (extension_loaded('gd') && function_exists('gd_info')) {
        echo "PHP GD library is installed on your web server";
    }

    if (extension_loaded('xml')) {
        echo "PHP XML installed on your web server";
    }
?>

See also

<? print_r(get_loaded_extensions());?>

You can use PhpCodeAnalyzer to static analyze your code to finds usage of PHP extensions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top