What should I do if PHP receives garbled post parameters?

藏色散人
Release: 2023-03-05 17:10:02
Original
3076 people have browsed it

Solution to php receiving garbled post parameters: First open the PHP file; then change the "header" code to "echo '

What should I do if PHP receives garbled post parameters?

Recommended: "PHP Video Tutorial"

Solution to php receiving garbled post parameters:

Specific problem:

PHP $_POST submits Chinese garbled characters

html: 

{$pro_name}

价格:¥{$pro_price}

已售出:{$pro_sale}件 数量
action: public function add(){ $user = session("user_name"); if(session("user_name")){ header("Content-Type:text/html;charset=utf8"); request.setCharacterEncoding("UTF-8"); $common = D("Common"); $data["user_id"] = $user[0]["user_id"]; $data["user_name"] = $user[0]["user_name"]; $data["pro_id"] = $_POST["pro_id"]; $data["pro_name"] = $_POST["pro_name"]; $data["pro_price"] = $_POST["pro_price"]; $data["pro_num"] = $_POST["pro_num"]; $data["pro_total"] = $_POST["pro_num"]*$_POST["pro_price"]; dump($data); echo $data["pro_name"]; } }
Copy after login

Why is the received $_POST["pro_name"] garbled? I checked the source code of the page and the hidden field is not garbled

Solution:

header("Content-Type:text/html;charset=utf8");
Copy after login

Modify to

echo '';
Copy after login

The above is the detailed content of What should I do if PHP receives garbled post parameters?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
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!