Home  >  Article  >  Backend Development  >  What should I do if php curl obtains a garbled title title?

What should I do if php curl obtains a garbled title title?

藏色散人
藏色散人Original
2021-05-24 09:15:312049browse

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?".

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

Question

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:
curl 乱码

Solution

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
What should I do if php curl obtains a garbled title title?
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

What should I do if php curl obtains a garbled title title?

Recommended study: "PHP Video Tutorial"

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!

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