Home  >  Article  >  Backend Development  >  Sending a post using a browser returns normal data, but using php curl returns garbled characters.

Sending a post using a browser returns normal data, but using php curl returns garbled characters.

PHP中文网
PHP中文网Original
2017-03-30 16:47:223707browse

Using a browser to send a post returns normal data. Using php curl returns garbled characters

The header is filled correctly
Such garbled characters:�
Is the returned data encrypted?

I figured it out myself. The returned data was compressed by gzip, and curl needs to be decompressed to work properly. Thank you.

Reply content:

The header is filled correctly
Such garbled characters:�
Is the returned data encrypted?

I figured it out myself. The returned data was compressed by gzip, and curl needs to be decompressed to work properly. Thank you.

See what character set is returned, use iconv to convert to your current character set

Add a sentence to CURL:

curl_setopt($ch, CURLOPT_ENCODING, "");

Encoding problem, check what encoding the site you requested uses (such as utf-8/gbk), and unify Next

The above is using a browser to send post return data. Normally using php curl returns garbled content. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

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