PHP: Call to undefined function gzdecode()

前端 未结 3 456
花落未央
花落未央 2020-12-17 17:28

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)         


        
相关标签:
3条回答
  • 2020-12-17 18:08

    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)); 
    } 
    
    0 讨论(0)
  • 2020-12-17 18:20

    gzdecode is not available unless PHP is complied with zlib. It will possibly be included in PHP 6, according to some sources. Notice in the manual how nearly all functions have given a PHP version number when it became / is available. Oddly, they don't think it needed to display a warning message.

    Try this code (works for me) for gzdecode without checksums:

    function gzdecode($data) 
    { 
       return gzinflate(substr($data,10,-8)); 
    } 
    
    0 讨论(0)
  • 2020-12-17 18:21

    Function gzdecode is available since php 5.4

    My favorite solution is

    Uncompress gzip compressed http response

    0 讨论(0)
提交回复
热议问题