从php检测MySQL querycache nativedriver

i need to detect from php if mysql query cache plugin is installed, any idea? http://forge.mysql.com/wiki/MySQLnd_Query_Cache_Plugin_for_PHP Thanks

Considering this is a PHP extension, you could use the extension_loaded() function to check if its loaded.

If its name is mysql_qc, you could use :

if (extension_loaded('mysql_qc')) {
    // its is loaded, use it
}


Else, you could use function_exists(), to check if one of the functions it exports exists.

For example, to check if the mysqlnd_qc_get_cache_info() function exists :

if (function_exists('mysqlnd_qc_get_cache_info')) {
    // That function exists, use it
}


Note that the second solution will return true even if that function has been created on the PHP-side, and not exported by an extension.

So, if you want to know if an extension is enabled, the first solution is the one you should use -- after all, that's why it exists.

My preferred way of checking if an extension is loaded that I've never used before is to view phpinfo in a web browser as you will also be shown all related variables for that extension and often you'll find something that needs tweaking.

<?php phpinfo(); ?>

If, I'm familiar with the extension and its options then I just check the list of installed extensions from the command line

php -m