Chinese garbled characters appear on the php page. how can this problem be solved?

Source: Internet
Author: User
Chinese garbled characters appear on the php page. please solve the problem by using index. php file code & lt; html & gt; & lt; head & gt; & lt; title & gt; Message Board & lt; title & gt; & lt; metahttp-equiv & quot; content-Type & quot; content & quot; texthtml; charsetgb2312 & quot; Chinese garbled characters appear on the php page. solution:
Index. php file code


Message Board




Message Board






$ F = fopen ("text.txt", "a + ");
$ Message = fread ($ f, filesize ("text.txt "));
Fclose ($ f );
Print $ message;
?>


Write message



Write1.php code






Untitled Document





Print "message board ";
?>





Write. php code


Message Board




$ Name = $ _ POST ["name"];
$ Email = $ _ POST ["email"];
$ Note = $ _ POST ["note"];
If ($ name = "") print ", enter the user name! ";
Else if ($ email = "") print ", enter your email address! ";
Else if ($ note = "") print "Please enter a message! ";
Else
{
$ File = fopen ("text.txt", "a + ");
$ Time = date ("F j, Y, g: I ");
$ Main = "User: $ name $ time
Message: $ note
";
$ Write = fwrite ($ file, $ main );
Fclose ($ file );
Print" Submitted successfully!
";
}
?>
Continue message

View messages




All three of my files are encoded in gb2312 format, but garbled characters still appear when I enter Chinese characters in the text box.
After being changed to UTF-8 encoding, Chinese characters in the code are garbled, but Chinese characters are not entered in the text box. please explain.


------ Solution --------------------
Save notepad as the encoding, which is consistent with the charset in the file.

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.