Ubuntu PHP server garbled problem

coldplay.xixi
Release: 2023-03-02 22:54:01
Original
2044 people have browsed it

ubuntu PHP server garbled solution: 1. Make the encoding of the PHP file itself match the encoding of the web page; 2. Make the encoding of PHP and the database consistent. The code is [mysql_query("set names 'encoding '");].

Ubuntu PHP server garbled problem

ubuntu PHP server garbled solution:

1: PHP web page encoding:

The encoding of the php file itself should match the encoding of the web page:

If you want to use gb2312 encoding, then the php header should output:

header(“Content-Type: text/html; charset=gb2312")
Copy after login

Static page addition

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
Copy after login

2: The coding of PHP and database should be consistent

Add

mysql_query("set names &#39;编码&#39;");
Copy after login

before the PHP program that needs to perform database operations to make the coding and PHP coding consistent

Check where coding is involved to see if the coding settings are consistent

Related learning recommendations:PHP programming from entry to proficiency

The above is the detailed content of Ubuntu PHP server garbled problem. 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!