How to check if memcache or memcached is installed for PHP?

前端 未结 10 764
猫巷女王i
猫巷女王i 2020-12-23 13:47

How do I test if memcache or memcached (for PHP) is installed on my Apache webserver?

Memcache is a caching daemon designed especiall

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 14:01

    The best approach in this case is to use extension_loaded() or function_exists() they are equally as fast.

    You can see evidence here:

    https://github.com/dragoonis/ppi-framework/blob/master/Cache/Memcached.php#L140

    Bear in mind that some PHP extensions such as APC have php.ini settings that can disable them even though the extension may be loaded. Here is an example of how to check against that also:

    https://github.com/dragoonis/ppi-framework/blob/master/Cache/Apc.php#L79

    Hope this helps.

提交回复
热议问题