Home  >  Article  >  Backend Development  >  How to solve the php gzip garbled problem

How to solve the php gzip garbled problem

藏色散人
藏色散人Original
2020-10-06 14:19:492825browse

php gzip is garbled because the returned content is compressed by gzip. The solution is to add "curl_setopt($curl, CURLOPT_ENCODING, 'gzip');" to the curl request.

How to solve the php gzip garbled problem

Recommendation: "PHP Video Tutorial"

PHP Curl Content-Encoding: Solving gzip garbled problem

In the process of using php curl to connect hugegraph, I found that sending results to gremlin returned garbled characters. The screenshot is as follows:

Compare this request with ordinary requests:

It is found that the garbled request that returns garbled characters contains Content-Encoding: gzip, that is, the returned content is compressed by gzip, so you need to add

curl_setopt($curl, CURLOPT_ENCODING, 'gzip');

to the curl request to return to normal.

The above is the detailed content of How to solve the php gzip garbled problem. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn