想做一个安装程序,里面有一项就是检测是否安装了gd库。如何写代码。也就是如何在一个php文件中,写几行代码,就能判断出环境是否已加载了gd库。
解决方案 »
- 怎么汉化zend studio7.1.0
- 求PHP开发环境的搭建
- 求助怎样用for循环使变量名称递增?急!急!急!
- eregi的乱码问题
- 一个组合问题: 输出从0到10中取出5个 的所有组合
- 请教怎么让html默认编码和apache2的AddDefaultCharset 不一样啊
- 我在安装PHP中出现的问题
- 有一些在线生成安卓应用apk程序的网站,他是什么思路,怎么做到的?
- 我是用delphi的,现在想转入php,不知她前景如何,请各位兄弟告之!
- php正则表达式如何获取内容中的视频地址和标题??急
- 怎么解决无网络调试php的问题?
- 大家好,php显示flash的问题,firefox和google可以显示,ie8不显示
#2.function_exists //用来判断扩展库里的某个方法存不存在
function_exists()function_exists
(PHP 4, PHP 5)function_exists — Return TRUE if the given function has been defined说明
bool function_exists ( string $function_name )
Checks the list of defined functions, both built-in (internal) and user-defined, for function_name. 参数function_name
The function name, as a string.
返回值
Returns TRUE if function_name exists and is a function, FALSE otherwise. Note: This function will return FALSE for constructs, such as include_once() and echo().
范例Example #1 function_exists() example<?php
if (function_exists('imap_open')) {
echo "IMAP functions are available.<br />\n";
} else {
echo "IMAP functions are not available.<br />\n";
}
?> get_loaded_extensions ()get_loaded_extensions
(PHP 4, PHP 5)get_loaded_extensions — Returns an array with the names of all modules compiled and loaded说明
array get_loaded_extensions ([ bool $zend_extensions = false ] )
This function returns the names of all the modules compiled and loaded in the PHP interpreter. 参数zend_extensions
Only return Zend extensions, if not then regular extensions, like mysqli are listed. Defaults to FALSE (return regular extensions).
返回值
Returns an indexed array of all the modules names. 更新日志
版本 说明
5.2.4 The optional zend_extensions parameter was added
范例Example #1 get_loaded_extensions() Example<?php
print_r(get_loaded_extensions());
?>
以上例程的输出类似于:Array
(
[0] => xml
[1] => wddx
[2] => standard
[3] => session
[4] => posix
[5] => pgsql
[6] => pcre
[7] => gd
[8] => ftp
[9] => db
[10] => calendar
[11] => bcmath
)
(PHP 3 >= 3.0.10, PHP 4, PHP 5)extension_loaded -- Find out whether an extension is loaded
Description
bool extension_loaded ( string name )
Returns TRUE if the extension identified by name is loaded, FALSE otherwise. 例子 1. extension_loaded() example<?php
if (!extension_loaded('gd')) {
if (!dl('gd.so')) {
exit;
}
}
?>
函数搞定,这个是我这边打印出来的:Array
(
[0] => bcmath
[1] => calendar
[2] => com_dotnet
[3] => ctype
[4] => session
[5] => filter
[6] => ftp
[7] => hash
[8] => iconv
[9] => json
[10] => odbc
[11] => pcre
[12] => Reflection
[13] => date
[14] => libxml
[15] => standard
[16] => tokenizer
[17] => zlib
[18] => SimpleXML
[19] => dom
[20] => SPL
[21] => wddx
[22] => xml
[23] => xmlreader
[24] => xmlwriter
[25] => apache2handler
[26] => gd
[27] => mbstring
[28] => mssql
[29] => mysql
[30] => mysqli
[31] => PDO
[32] => pdo_mysql
[33] => SQLite
[34] => Zend Optimizer
)