Solution to php receiving garbled post parameters: First open the PHP file; then change the "header" code to "echo '
Recommended: "PHP Video Tutorial"
Solution to php receiving garbled post parameters:
Specific problem:
PHP $_POST submits Chinese garbled characters
html: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"]; } }
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");
Modify to
echo '';
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!