php curl gets the garbled title solution: first open the corresponding PHP code file; then find the code that executes curl; and finally transcode the text through "mb_convert_What should I do if php curl obtains a garbled title title?".
The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer
Solution to the Chinese garbled content obtained by PHP curl
I want to get movie information from Movie Paradise using curl
, garbled characters appear in the What should I do if php curl obtains a garbled title title?s, as shown in the figure:
There is a CURLOPT_ENCODING
option in the official document, try Yes, it's actually of no use.
We see that the header of the page explains the What should I do if php curl obtains a garbled title title? GB2312
It should be like this
//curl 前面的设置不冗述 //执行 curl $outPageTxt = curl_exec($film); //outPageTxt 是得到的网页文本 curl_close($film); //文本转码 $outPageTxt = mb_convert_What should I do if php curl obtains a garbled title title?($outPageTxt, 'utf-8','GB2312'); //把 GB2312 转到 UTF-8 echo $outPageTxt;
Instructions for use
mb_convert_What should I do if php curl obtains a garbled title title?(output variable, What should I do if php curl obtains a garbled title title? to switch to, what What should I do if php curl obtains a garbled title title? to convert from)
Result
The above is the detailed content of What should I do if php curl obtains a garbled title title?. For more information, please follow other related articles on the PHP Chinese website!