Home  >  Article  >  Backend Development  >  Ubuntu PHP server garbled problem

Ubuntu PHP server garbled problem

coldplay.xixi
coldplay.xixiOriginal
2020-07-23 10:09:332068browse

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")

Static page addition

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

2: The coding of PHP and database should be consistent

Add

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

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!

Statement:
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
Previous article:How to set cookies in phpNext article:How to set cookies in php