The php array object has Chinese characters and the output is garbled.

coldplay.xixi
Release: 2023-03-03 18:18:01
Original
2951 people have browsed it

The php array object has Chinese characters and the solution is to output garbled characters: 1. Add code at the beginning of the page and save the [UTF-8] encoded file. The code is [header("Content-type:. ..=utf-8")]; 2. Add database encoding before data query, modification, and addition.

The php array object has Chinese characters and the output is garbled.

The php array object contains Chinese characters and the output is garbled. Solution:

1. Chinese garbled characters in pure PHP pages Problem (the data is static)

You only need to add the following code at the beginning of the page, and then save the UTF-8 encoded file.

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

2. PHP Mysql Chinese garbled problem

In addition to following the operations mentioned in the first point, you must also add database encoding before querying/modifying/adding your data. Moreover, it is worth noting that the UTF8 here is different from the previous one, there is no horizontal line in the middle.

<?php
mysql_query(&#39;SET NAMES UTF8&#39;);
//接下来的就是查出数据或者修改,增加
?>
Copy after login

Related learning recommendations: php graphic tutorial

The above is the detailed content of The php array object has Chinese characters and the output is garbled.. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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!