Page 1 of 1

Checking for installed PHP extentions [solved]

Posted: Mon May 09, 2005 12:33 am
by php_wiz_kid
Is it possible to check for installed PHP extentions? I would like to check to see if the mysql or mysqli extensions are installed. Thanks.

Posted: Mon May 09, 2005 4:25 am
by Chris Corbyn
Do you mean as part of an application or just in general?

Code: Select all

<? phpinfo(); ?>
Otherwise (untested but) I guess you could do something with ini_get();

Posted: Mon May 09, 2005 5:31 am
by timvw

Code: Select all

<?php
if (!function_exists('mysql_connect'))
{
  echo "mysql extension is not loaded.";
}
if (!function_exists('mysqli_connect'))
{
  echo "mysqli extension is not loaded.";
}
?>

Posted: Mon May 09, 2005 5:33 am
by timvw
Just use the extension_loaded function...

Posted: Mon May 09, 2005 5:41 am
by Chris Corbyn
Doh.... I never even considered function_exists() for built-in functions :oops:

I use that a lot too in larger apps with custom functions :P

Posted: Mon May 09, 2005 3:32 pm
by php_wiz_kid
extension_loaded works great. Thanks.