title: gzip encode/deflate STRING in bash, then decode/inflate STRING in php
body: <p>I wish to produce a gzip'ed STRING in bash, and then send it to a php script for decoding/inflating.  But I am coming across a problem with, I think, the gzip'ed string produced by gzip in bash.</p>
  
  <pre><code>    # from 
      # https://stackoverflow.com/questions/7538846/un-decompress-a-string-in-bash#7539075
      FOO="$(echo "Hello world" | gzip -c | base64)" # compressed, base64 encoded data
      echo $FOO | base64 -d | gunzip # use base64 decoded, uncompressed data
      echo '--'
  
      # unpack base64 again before sending to php
      FOO="$(echo $FOO | base64 -d)"
  
      # this is where it goes wrong:
      # php doesn't seem to like the gzip string format.
  
      # gzuncompress produces:
      #   PHP Warning:  gzuncompress(): data error in Command line code on line 1
      php -r "echo gzuncompress('$FOO') . \"\n\";"
      echo '--'
  
      # gzdecode produces:
      #   PHP Warning:  gzdecode(): data error in Command line code on line 1
      php -r "echo gzdecode('$FOO') . \"\n\";"
      echo '--'
  
      # gzinflate produces:
      #   PHP Warning:  gzinflate(): data error in Command line code on line 1
      php -r "echo gzinflate('$FOO') . \"\n\";"
      echo '--'
  </code></pre>
  
  <p>I am suspecting that the problem may be with the bash gzip format.<br>
  But I am unable to see any options that might correct this.</p>
  
  <p>All thoughts appreciated.</p>