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

藏色散人
Release: 2023-03-07 22:44:02
Original
2172 people have browsed it

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!