Home >Backend Development >PHP Problem >How to solve php curl getting garbled characters
The solution for php curl to obtain garbled characters: first open the corresponding script file; then obtain the web page text; finally convert GB2312 through the "b_convert_How to solve php curl getting garbled characters($outPageTxt, 'utf-8','GB2312');" method to "UTF-8".
Recommended: "PHP Video Tutorial"
##Problem I want to get movie information from Movie Paradise usingcurl, but garbled characters appear in the How to solve php curl getting garbled characterss, as shown in the picture:
CURLOPT_ENCODING option in the official documentation. I tried it, but it actually has no use.
We see that the How to solve php curl getting garbled characters is explained in the header of the page
GB2312
##It should be like this
//curl 前面的设置不冗述 //执行 curl $outPageTxt = curl_exec($film); //outPageTxt 是得到的网页文本 curl_close($film); //文本转码 $outPageTxt = mb_convert_How to solve php curl getting garbled characters($outPageTxt, 'utf-8','GB2312'); //把 GB2312 转到 UTF-8 echo $outPageTxt;
mb_convert_How to solve php curl getting garbled characters (Output variable, code to switch to, what code to switch from)
Result
The above is the detailed content of How to solve php curl getting garbled characters. For more information, please follow other related articles on the PHP Chinese website!