How to solve php curl getting garbled characters

藏色散人
Release: 2023-03-05 20:12:01
Original
2839 people have browsed it

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

How to solve php curl getting garbled characters

Recommended: "PHP Video Tutorial"

##Problem

I want to get movie information from Movie Paradise using

curl, but garbled characters appear in the How to solve php curl getting garbled characterss, as shown in the picture:
curl 乱码

Solution

There is a

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 thisHow to solve php curl getting garbled characters

//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;
Copy after login

Instructions for use

mb_convert_How to solve php curl getting garbled characters (Output variable, code to switch to, what code to switch from)

Result

How to solve php curl getting garbled characters

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!