简体   繁体   English

PHP:如何检查是否已正确安装并启用了库?

[英]PHP: How to check whether a library has been properly installed and enabled?

Following another question on SO (I am no PHP expert), I am wondering whether the Zlib library has been properly installed on my local laptop. 关于SO的另一个问题 (我不是PHP专家),我想知道Zlib库是否已正确安装在本地笔记本电脑上。 Documentation says there should be no need to manually install this library, but code using this library does not work. 文档说不需要手动安装此库,但是使用该库的代码不起作用。

Documentation mentions a need to configure PHP --with-zlib[=DIR] , but for versions below 4.3. 文档提到需要配置PHP --with-zlib[=DIR] ,但低于4.3的版本需要配置。 I am on 5.2.17. 我在5.2.17。 I have checked php.ini , but I see no reference to it. 我已经检查了php.ini ,但是没有看到任何引用。 My PHP system has been installed with Acquia Dev Desktop . 我的PHP系统已随Acquia Dev Desktop一起安装。

How can I check whether the Zlib library has been properly installed and enabled on my local PC? 如何检查本地PC上是否已正确安装并启用Zlib库? Where should I take a look at? 我应该去哪里看看? What should I look for? 我应该找什么? Thanks. 谢谢。

You can use phpinfo() to get full information about libraries 您可以使用phpinfo()获得有关库的完整信息

<?php
   phpinfo();
?>

or in your PHP code test for a given function 或在您的PHP代码中测试给定功能

if (function_exists("gzcompress")) {
  echo "OK";
} else {
  die("zlib missing");
}

Unless I'm missing something: 除非我缺少任何东西:

var_dump(function_exists('gzclose')); // or any gz-related functions

Or to be more specific and correct 或者更具体和正确

if(extension_loaded('zlib'))

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

Make sure that, if you are using DevDesktop, you are referencing the Application/Devdesktop/php# version of PHP(links within DD prefs) (my dev machine has three: Mac OS, HomeBrew, and Acquia DevD).. 确保(如果使用的是DevDesktop)引用的是Application / Devdesktop / php#版本的PHP(DD首选项中的链接)(我的开发机具有三个:Mac OS,HomeBrew和Acquia DevD)。

I used Homebrew to tap that ^ keg and install the plugin (Mac). 我用Homebrew轻按了那个^桶并安装了插件(Mac)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM