I have to run a function that has an option to use GD or ImageMagick - what is the best way (php) to test if ImageMagick is installed, and return a true or false?
Asked
Active
Viewed 1.5k times
2 Answers
17
Use an if
condition with extension_loaded()
function to check whether you have the extension is loaded
if(extension_loaded('imagick')) {
echo 'Imagick Loaded';
}

Mr. Alien
- 153,751
- 34
- 298
- 278
-
@Mr.Alien - i am getting echo 'not installed' in else part ... how to install it ? – Hitesh Oct 16 '14 at 18:02
-
@hitesh http://php.net/manual/en/imagick.setup.php – Mr. Alien Oct 16 '14 at 18:37
0
Just create an if condition checking for installed extension
if (!extension_loaded('imagick'))
{
echo 'imagick not installed';
}
else
{
echo 'imagick installed';
}

Fabio
- 23,183
- 12
- 55
- 64