How to compress JSON with PHP?

前端 未结 3 1759
孤独总比滥情好
孤独总比滥情好 2020-12-13 14:46

I\'m writing a little analysis page which will help me hunt down bugs in an application. In essence it allows to visually compare actual data and log entries, plus perform a

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 15:32

    You can compress the data with PHP’s output control. Just put this call at the start of your script before any output:

    ob_start('ob_gzhandler');
    

    Now any output will be compressed with either gzip or deflate if accepted by the client.

提交回复
热议问题