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.