In this case, I want to write A file that contains two garbled characters for the Chinese part: A, index. php file code: PHPcode & lt ;! DOCTYPEhtmlPUBLIC & quot;-// W3C // DTDXHTML1.0Transitional // EN & quot; http: // a file containing www is written. why is the Chinese part garbled?
There are two files in total:
A, index. php file code:
PHP code
...test.....
B. Code of the title. php file:
PHP code
Chinese title (beta 1.0) ---- Powered by Aloesky
Test in the PHP environment, the above text "Chinese title" The words become garbled, no matter how declared UTF-8 is invalid
Please enlighten me
------ Solution --------------------
Are UTF-8 file encoding format must be consistent.
------ Solution --------------------
Because the file is not utf8, and the blank space is BOM, remove it.
------ Solution --------------------
Next: Notepad ++
A great code editor.
To remove the BOM that exists in the UTF-8 file, you just need to use NotePad ++ to open this file, then select "format", then select "code in UTF-8 no BOM format ", save the file again!
Remove BOM from UTF-8 files with Notepad ++
At the end of this article, I will introduce a small experience:
Do not be impatient when you encounter many strange problems (such as the blank line caused by BOM) in web page resolution (including CSS and HTML parsing, first, make sure that your code is correctly written. if the problem persists, submit the code to the W3C website for HTML verification and CSS verification. finally, correct your code based on the prompt of the verification result. Follow the W3C specifications as much as possible. generally, problems can be solved according to this process. W3C official website: http://validator.w3.org/