Home  >  Article  >  Backend Development  >  What should I do if php form submission displays garbled characters?

What should I do if php form submission displays garbled characters?

藏色散人
藏色散人Original
2020-12-04 10:01:052185browse

The solution to the garbled code displayed in PHP form submission: first determine the encoding method of the transmitted data; then use the header to declare "header("Content-type:text/html;charset=utf-8");"; finally Just declare the same encoding method on the receiving page.

What should I do if php form submission displays garbled characters?

The operating environment of this tutorial: Windows 7 system, PHP version 7.1. This method is suitable for all brands of computers.

Recommended: "PHP Video Tutorial"

First you determine the encoding method of the data you pass

You can use the header to declare header("Content-type :text/html;charset=utf-8");

Secondly, if the receiving page wants to be displayed normally, it must also have the same encoding method statement

Secondly, the encoding method is not in httpd.conf There is a charset setting in php.conf. This is just the default method. It is the most important to declare the encoding method in your page.

Summary method:

1, use utf-8 for all ;

2, the file is stored as utf-8 without bom header;

3, the database uses utf-8 general ci;

4, the Chinese in the url must be rawurlencode;

5, do not decode when parsing;

The above is the detailed content of What should I do if php form submission displays garbled characters?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn