少用但始终都会碰到 - 已加载的模块 ¶
作者:KK
发表日期:2017.3.22
phpinfo 基本查看 ¶
一般我们都会在页面上执行phpinfo()
输出HTML信息,我们可以在里面找到许多已经启用加载的模块信息和具体配置。
代码判断是否加载了模块 ¶
比如判断是否加载了xdebug模块:
var_dump(extension_loaded('xdebug'));
会返回true/false表示是否已经加载
代码获取所有加载的模块列表 ¶
print_r(get_loaded_extensions());
//结果大致如下:
Array
(
[0] => Core
[1] => bcmath
[2] => calendar
[3] => ctype
[4] => date
[5] => filter
[6] => hash
[7] => iconv
[8] => json
[9] => mcrypt
[10] => SPL
[11] => pcre
[12] => Reflection
[13] => session
[14] => standard
[15] => mysqlnd
[16] => tokenizer
[17] => zip
[18] => zlib
[19] => libxml
[20] => dom
[21] => PDO
[22] => bz2
[23] => SimpleXML
[24] => xml
[25] => wddx
[26] => xmlreader
[27] => xmlwriter
[28] => cgi-fcgi
[29] => openssl
[30] => curl
[31] => fileinfo
[32] => gd
[33] => mbstring
[34] => mysqli
[35] => Phar
[36] => pdo_mysql
[37] => PDO_ODBC
[38] => pdo_sqlite
[39] => soap
[40] => sqlite3
)
命令行模式下查看启用的模块 ¶
php -m
就会输出模块列表:
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
fileinfo
filter
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
SimpleXML
soap
SPL
sqlite3
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]