Home > Article > Backend Development > Sending a post using a browser returns normal data, but using php curl returns garbled characters.
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.
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)!