查看php已安装扩展模块的几种方法
linux命令行下查看扩展是否开启
使用 php -m 命令
$ php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
ereg
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mysql
mysqli
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
Xdebug
查看具体哪个扩展可以结合grep,如查看gd
$ php -m | grep -i gd
gd
phpinfo浏览器查看php扩展库
<?php
phpinfo();
页面显示的每一个表格的标题,即是已经安装的扩展。
get_loaded_extensions获取开启的所有PHP扩展
<?php
print_r(get_loaded_extensions());
Array
(
[0] => Core
[1] => date
[2] => ereg
[3] => libxml
[4] => openssl
[5] => pcre
[6] => sqlite3
[7] => zlib
[8] => bcmath
[9] => ctype
[10] => curl
[11] => dom
[12] => fileinfo
[13] => filter
[14] => gd
[15] => hash
[16] => json
[17] => mbstring
[18] => SPL
[19] => session
[20] => standard
[21] => mysqlnd
[22] => PDO
[23] => pdo_sqlite
[24] => Phar
[25] => posix
[26] => Reflection
[27] => mysqli
[28] => SimpleXML
[29] => mysql
[30] => tokenizer
[31] => xml
[32] => xmlreader
[33] => xmlwriter
[34] => zip
[35] => cgi-fcgi
[36] => iconv
[37] => xdebug
)
extension_loaded判断php扩展是否加载
<?php
var_dump(extension_loaded('gd'));
// 输出true 或者 false