运行以下内容:
foreach(get_loaded_extensions() as $name){
$extensions[strtolower($name)] = phpversion($name);
}
var_dump($extensions);
我注意到一些加载的扩展没有显示版本,例如:
'pcre' => boolean false
但是,当我点击phpinfo()
时,会显示版本号:
为什么phpversion()
函数不能获取正确的结果?我理解在这个例子中我可以简单地拉PCRE_VERSION
,但是需要这样做而不是所有扩展都是愚蠢的; gd
也显示为假。
修改:修复;
foreach(get_loaded_extensions() as $name){
$extensions[strtolower($name)] = phpversion($name);
}
$extensions = array_replace($extensions, array(
'iconv' => ICONV_VERSION,
'pcre' => PCRE_VERSION,
'libxml' => LIBXML_DOTTED_VERSION,
'gd' => GD_VERSION,
// others i may be missing, will get to it
));
编辑:这是完整转储和phpinfo()
输出,仅适用于咯咯笑声:
array
'core' => string '5.3.8' (length=5)
'bcmath' => boolean false
'calendar' => boolean false
'com_dotnet' => string '0.1' (length=3)
'ctype' => boolean false
'date' => string '5.3.8' (length=5)
'ereg' => boolean false
'filter' => string '0.11.0' (length=6)
'ftp' => boolean false
'hash' => string '1.0' (length=3)
'iconv' => boolean false
'json' => string '1.2.1' (length=5)
'mcrypt' => boolean false
'spl' => string '0.2' (length=3)
'odbc' => string '1.0' (length=3)
'pcre' => boolean false
'reflection' => string '$Revision: 313665 $' (length=19)
'session' => boolean false
'standard' => string '5.3.8' (length=5)
'mysqlnd' => string 'mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $' (length=50)
'tokenizer' => string '0.1' (length=3)
'zip' => string '1.9.1' (length=5)
'zlib' => string '1.1' (length=3)
'libxml' => boolean false
'dom' => string '20031129' (length=8)
'pdo' => string '1.0.4dev' (length=8)
'bz2' => boolean false
'simplexml' => string '0.1' (length=3)
'wddx' => boolean false
'xml' => boolean false
'xmlreader' => string '0.1' (length=3)
'xmlwriter' => string '0.1' (length=3)
'apache2handler' => boolean false
'phar' => string '2.0.1' (length=5)
'mbstring' => boolean false
'exif' => string '1.4 $Id: exif.c 314376 2011-08-06 14:47:44Z felipe $' (length=52)
'gd' => boolean false
'gettext' => boolean false
'imap' => boolean false
'mysql' => string '1.0' (length=3)
'mysqli' => string '0.1' (length=3)
'pdo_mysql' => string '1.0.2' (length=5)
'pdo_odbc' => string '1.0.1' (length=5)
'pdo_sqlite' => string '1.0.1' (length=5)
'soap' => boolean false
'sockets' => boolean false
'sqlite' => string '2.0-dev' (length=7)
'sqlite3' => string '0.7-dev' (length=7)
'tidy' => string '2.0' (length=3)
'xmlrpc' => string '0.51' (length=4)
'mhash' => boolean false
'xdebug' => string '2.1.1' (length=5)
答案 0 :(得分:3)
phpversion()返回该扩展的版本,如果存在,则返回FALSE 没有关联的版本信息或未启用扩展名。
您在phpinfo()
中看到的不是扩展程序的版本信息,而是库的c-client版本。 prce
扩展程序本身没有版本信息。