Home > Backend Development > PHP Tutorial > ThinkPHP solves the problem of Chinese garbled characters when obtaining physical addresses using pure IP

ThinkPHP solves the problem of Chinese garbled characters when obtaining physical addresses using pure IP

little bottle
Release: 2023-04-06 11:02:01
forward
3961 people have browsed it

The main content of this article is to solve the problem of Chinese garbled characters when obtaining the physical address using pure IP. It has certain reference value. Friends who are interested can learn about it.

Today when I used ThinkPHP to obtain the address through Pure IP, I found that the output result was garbled in Chinese, as shown in the picture:

After checking, I found the IpLocation of ThinkPHP The .class.php class file states: "Because UTF8 encoding is used, if the innocent IP address library is used, the return result needs to be encoded." After all, modifying the browser encoding is not a long-term solution, so I tried to define it through An array encoding conversion method, as shown in the figure:

At this time, modify the getArea method code as follows:

Re-run the problem Solution:

Related tutorials:

PHP video tutorial

The above is the detailed content of ThinkPHP solves the problem of Chinese garbled characters when obtaining physical addresses using pure IP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
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
Latest Articles by Author
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template