PHP page garbled appearance of a number of reasons, one is the page encoding does not count one, the second is the database does not set the code, the third is the Apache coding problem, I would like to introduce two solutions, the overall is the page code is not unified.
Most of the garbled is due to inconsistent coding methods, of which there are four major inconsistencies may exist this possibility:
1, the page file encoding method (. html,.php, etc.)
2, the html.head of the specified browser encoding method
3, the MySQL database transmission coding mode
4. Apache Character Set
In only PHP code page, do JS window, if the window content contains Chinese, there may be garbled problems,
Workaround, one line of code:
Page Chinese garbled
Copy Code code as follows:
Header ("content-type:text/html; Charset=utf-8 ");
Database is garbled
Copy Code code as follows:
. <?php
mysql_query (' SET NAMES UTF8 ');
The next thing is to identify the data or modify it, increase it
?>
Attention:
1, this code must be placed at the top of the file, ' <?php ' after;
2, CharSet value to see the entire site code, if it is gb2312, then fill in the gb2312.