Why is the Chinese part garbled when I write a file containing this file?

Source: Internet
Author: User
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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.