Home > Article > Backend Development > Ubuntu PHP server garbled problem
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 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 '编码'");
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!