title: differ json from gzipp
body: <p><br>
  I have a follow implementation problem.<br>
  I am working with some api and I must upload image file and get result in gzipped format or a JSON error message.
  How can I differ json and gzipped files with php (I think they are resource type).
  I have one idea:<br>
  call json function to result and if error occured call php die function  .<br>
  But I don't think it's a best solution.</p>
  
  <p>Thank's</p>