PHP:调用未定义的函数gzdecode() [英] PHP: Call to undefined function gzdecode()

查看:174
本文介绍了PHP:调用未定义的函数gzdecode()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

if($ file_loc!= NULL){
if(file_exists($ file_loc)){
printf(file exists);
$ handle = fopen($ file_loc,rb);
$ contents = fread($ handle,filesize($ file_loc));
fclose($ handle);
$ result = gzdecode($ contents);


我基本上试图从gzip中加载文本内容文件。我得到以下错误:

 致命错误:调用未定义函数gzdecode()in ... \sites\MyScripts \fw2.php 80行

然而,当我看看文档,似乎并不需要包含额外的库,或者我错了?我怎样才能解决这个问题?



更新



=https://stackoverflow.com/questions/9802498/php-how-to-check-whether-a-library-has-been-properly-installed-and-enabled>问题检查是否这图书馆安装在我的电脑上,答案是肯定的,它是。



来自PHP信息:

< img src =https://i.stack.imgur.com/yEZFw.jpgalt =

所以这个越来越多了,更令人困惑... ...
$ b $ p UPDATE II


我曾尝试过:

p>

 <?php 

echo phpversion()。,;

if(function_exists(gzdecode)){
echogzdecode OK,;
} else {
echogzdecode no OK,;
}

if(extension_loaded('zlib')){
echozlib extension loaded;
} else {
echozlib extension not loaded;
}

?>

我得到:

  5.2.17,gzdecode no OK,已加载zlib扩展


解决方案

并不总是安装。从文档


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



Windows的PHP版本内置了对该扩展的支持。你不需要加载任何额外的扩展名来使用这些功能。


编辑:既然这是我接受的答案,编辑它以添加建议作为替换的函数。

$ p $ 函数gzdecode($ data){
return gzinflate(substr( $数据,10,-8));
}


I am getting a strange error message with the following piece of PHP code (I am not a PHP expert):

if ( $file_loc != NULL ) {
    if ( file_exists($file_loc) ) {
        printf(" file exists");
        $handle = fopen($file_loc, "rb");
        $contents = fread($handle, filesize($file_loc));
        fclose($handle);
        $result = gzdecode($contents);
    }
}

I am basically trying to load text content from a gzipped file. I get the following error:

Fatal error: Call to undefined function gzdecode() in ...\sites\MyScripts\fw2.php on line 80

Yet, when I take a look at documentation, it does not seem like I would need to include an extra library, or am I being wrong? How can I solve this issue?

UPDATE

Following another question to check whether this library is installed on my PC, the answer is yes, it is.

From PHP info:

So this is getting more and more confusing...

UPDATE II

I have tried:

<?php

echo phpversion().", ";

if (function_exists("gzdecode")) {
  echo "gzdecode OK, ";
} else {
  echo "gzdecode no OK, ";
}

if (extension_loaded('zlib')) {
  echo "zlib extension loaded ";
} else {
  echo "zlib extension not loaded ";
}

?>

and I get:

5.2.17, gzdecode no OK, zlib extension loaded 

解决方案

It's not always installed. From the documentation:

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

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.

edit: Since this is the accepted answer still, I edited it to add the function suggested as replacement.

function gzdecode($data) { 
   return gzinflate(substr($data,10,-8)); 
} 

这篇关于PHP:调用未定义的函数gzdecode()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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