Home > Article > Backend Development > ThinkPHP solves the problem of Chinese garbled characters when obtaining physical addresses using pure IP
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 tutorialThe 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!