What should I do if the Chinese output of php array is garbled?

青灯夜游
Release: 2023-03-08 22:16:02
Original
1955 people have browsed it

Solution to garbled Chinese output of php array: First add the "header("Content-type:text/html;charset=utf-8");" code at the beginning of the php document; then save the php document It can be in "UTF-8" format.

What should I do if the Chinese output of php array is garbled?

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

php array Chinese output garbled code

"猫","b"=>"狗","c"=>"兔子"); var_dump($arr1); ?>
Copy after login

Output:

array (size=3) 'a' => string '鐚�' (length=3) 'b' => string '鐙�' (length=3) 'c' => string '鍏斿瓙' (length=6)
Copy after login

Solution:

Add the following code at the beginning of the php page, and then save the UTF -8 encoded files are sufficient.

header("Content-type:text/html;charset=utf-8");
Copy after login

Output at this time:

array (size=3) 'a' => string '猫' (length=3) 'b' => string '狗' (length=3) 'c' => string '兔子' (length=6)
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if the Chinese output of php array is garbled?. 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
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!