The couple is different. You can simply check for a class or even a function: class_exists , function_exists and get_extension_funcs :
<?php if( class_exists( '\Memcached' ) ) {
You can also get super sophisticated and use ReflectionExtension . When you build it, it will throw a ReflectionException . If it does not throw an exception, you can check other things about the extension (e.g. version).
<?php try { $extension = new \ReflectionExtension( 'memcached' ); } catch( \ReflectionException $e ) { // Extension Not loaded } if( $extension->getVersion() < 2 ) { // Extension is at least version 2 } else { // Extension is only version 1 }
Ascherer
source share