Checking for installed PHP extentions [solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Checking for installed PHP extentions [solved]

Post 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.
Last edited by php_wiz_kid on Mon May 09, 2005 3:32 pm, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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();
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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.";
}
?>
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Just use the extension_loaded function...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post by php_wiz_kid »

extension_loaded works great. Thanks.
Post Reply