Add to Favorites

function_exists to test if extension is installed

Many make use of GD through php to resize and process images. Some hosting environments do not have php compiled with GD support. If your script is run on one of those hosting environments it will fail. If you plan on distributing your script you can add some tests to see if GD is installed, a very basic way to test for it would be to see if a function that extension provides has been defined.

if ( ! function_exists('imagecreate') ) {

die('GD must be installed to use this script');


You can then program any kind of reaction you want to this missing function, whether it is an error message or some alternate behavior.


Be the first to leave a comment on this post.

Leave a comment

To leave a comment, please log in / sign up