默认情况下是否启用PHP中的ZLIB支持? [英] Is ZLIB support in PHP enabled by default or NOT?

查看:252
本文介绍了默认情况下是否启用PHP中的ZLIB支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在phpmanual的文档中说:

In the documentation of phpmanual it says:

默认情况下未启用PHP中的Zlib支持.您将需要 配置PHP --with-zlib [= DIR]

Zlib support in PHP is not enabled by default. You will need to configure PHP --with-zlib[=DIR]

Windows版本的PHP对此扩展具有内置支持. 您无需加载任何其他扩展名即可使用 这些功能.

The Windows version of PHP has built-in support for this extension. You do not need to load any additional extensions in order to use these functions.

正如它所说的,默认情况下,仅应在Windows版本的PHP中启用它.

So as it says it should be enabled by default only in the Windows version of PHP.

但是我从存储库中在Linux机器上安装了PHP和Apache,然后我注意到它已经启用.使用了这些命令:

But I install PHP and Apache on my linux machine from the repository, and then I noticed that it's already enabled. Used those commands:

sudo apt-get install apache2
sudo apt-get install php5 php-pear

这是否意味着如果您从存储库中安装PHP,默认情况下也会启用该功能?

Does this mean that is also enabled by default if you install PHP from the repository?

我还尝试从源代码安装PHP,而没有添加--with-zlib[=DIR]配置,只是为了检查是否支持zlib.根据phpmanual上的文档,不应该.

Also I tried to install PHP from source code without adding --with-zlib[=DIR] configuration, just to check will zlib be supported or not. According to documentation on phpmanual it shouldn't.

我不是编译专家,所以我找到了从源代码安装php的教程,然后进行了下一步:

I am not expert in compiling so I found tutorial for installing php from source code and I did next steps:

apt-get install libxml2-dev
apt-get install build-essential

wget http://in1.php.net/distributions/php-5.3.28.tar.bz
tar -xvjf php-5.3.28.tar.bz
cd php-5.3.28
./configure --prefix /usr/local/php5
------ I configure it without --with-zlib[=DIR]    ---------
make
make test
make install

最后,我运行此行以使其与apache兼容:

and as last I run this line to have it work with apache:

apt-get install libapache2-mod-php5

以这种方式安装PHP之后,默认情况下再次启用了ZLIB支持.

And after installing PHP on this way ZLIB support was again enabled by default.

如果您问自己如何检查我是否启用了此功能,则为答案.

If you are asking yourself how am I checking is it enabled or not, here is the answer.

我正在检查它phpinfo();,它总是说它已启用:

I am checking it phpinfo(); and it always says it is enabled:

我也正在检查该库中的一些功能:

And also I was checking for few function from this library:

if(function_exists('gzdeflate'))
{
    echo 'ZLIB is supported';
}
else
{
    echo 'ZLIB is not supported';
}
//the result is always 'ZLIB is supported'

if(function_exists('gzencode'))
{
   echo 'ZLIB is supported';
}
else
{
    echo 'ZLIB is not supported';
}
//the result is always 'ZLIB is supported'

我问这是因为我有wordpress插件.因此,作为插件,它将安装在许多不同的服务器上. 现在,我想开始将功能gzinflate()gzdeflate()用于一项新功能.因此,我进行了研究和一些测试,并感到困惑,因为文档说默认情况下不支持它,但是当我在服务器上安装PHP时,默认情况下始终支持它.

I am asking this because I have wordpress plugin. So as plugin it will be installed on many different servers. Now I want to start with using functions gzinflate() and gzdeflate() for one new feature. So I did research and some tests and was confused because documentation says it is not supported by default but when I install PHP on my server it is always supported by default.

我确实需要使用这些功能,但是如果至少有99%的客户服务器不支持该功能,我就不想使用它们.

I really need to use those functions but I don't want to use them if it will not be supported on at least 99% of customers servers.

说明文件有误还是我遗漏了一些东西?如果我丢失了某些东西,那么您能为我提供任何其他压缩功能,至少在99%的服务器上受支持.

So is documentation wrong or am I missing something. If I am missing something then can you help me with any alternative functions for compressing which will be supported on at least 99% of servers.

推荐答案

文档的本部分似乎不正确.据我所知,zlib扩展名始终*默认为启用.

This section of the documentation appears to be incorrect. As far as I can tell, the zlib extension has always* been enabled by default.

虽然某些系统上可能未加载此扩展名,但这种情况极为罕见.您无需为缺少它而添加解决方法-只需将其声明为要求并继续即可.

While it's possible that this extension is not loaded on some systems, this is extremely rare. You do not need to add workarounds for its absence — just state it as a requirement and move on.

*:也就是说,至少回到 PHP 4.0.

*: That is, back to at least PHP 4.0.

这篇关于默认情况下是否启用PHP中的ZLIB支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆