Check if MongoDB PHP Driver is installed

谁说胖子不能爱 提交于 2020-01-01 04:55:20

问题


I am developing an install script for my application, how would I go about checking if MongoDB is installed or not with a PHP driver on a server??

Many thanks


回答1:


The easiest way of checking it would be to run:

echo extension_loaded("mongo") ? "loaded\n" : "not loaded\n";

See also: http://php.net/manual/en/function.extension-loaded.php




回答2:


get_loaded_extensions — Returns an array with the names of all modules compiled and loaded.

print_r(get_loaded_extensions());



回答3:


You can check by using class_exists

if (class_exists('Mongo')) {
   // MongoDB is installed
}
else {
   // MongoDB is not installed
}


来源:https://stackoverflow.com/questions/11134959/check-if-mongodb-php-driver-is-installed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!