gzuncompress, catching errors

Discussion in 'PHP' started by fcmisc, Feb 7, 2008.

  1. #1
    How do I detect whether or not a string has been compressed?

    I'm getting the following error:

    warning: gzuncompress() [function.gzuncompress]: data error

    I'd like to test the data before passing it to gzuncompress, but can't find the required function.

    Cheers,

    fcmisc.
     
    fcmisc, Feb 7, 2008 IP
  2. daman371

    daman371 Peon

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The only way I can think of helping with your problem is by using the gzuncompress function to check to see if it has been compressed.

    
    if (!gzuncompress($string))
    {
    //string hasn't been compressed
    }
    else
    {
    //string has been compressed
    }
    
    PHP:
     
    daman371, Feb 7, 2008 IP