Solution to garbled php submission parameters: 1. Open the corresponding PHP file; 2. Check the "$_POST["pro_name"]" code; 3. Modify the content to "echo '';" is enough.
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.
What should I do if the php submission parameters are garbled?
Problem description:
PHP $_POST submits Chinese garbled characters
html: <form action="__APP__/ShoppingCart/add" method="POST"> <br/><b>{$pro_name}</b><br/><br/> 价格:¥{$pro_price}<br/><br/> 已售出:{$pro_sale}件 数量<input type="text" size="2" name="pro_num" value="1"/><input type="submit" value="加入购物车" /> <input type="hidden" name="pro_id" value="{$pro_id}" /> <input type="hidden" name="pro_name" value="{$pro_name}" /> <input type="hidden" name="pro_price" value="{$pro_price}" /> </form> 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 have checked the source code of the page and the hidden field has not become garbled
Solution:
header("Content-Type:text/html;charset=utf8");
is changed to
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
Recommended study: " PHP video tutorial》
The above is the detailed content of What to do if php submission parameters are garbled. For more information, please follow other related articles on the PHP Chinese website!

C++作为一种高效的编程语言,因其可靠性被广泛应用于各种各样的领域。但是,在编写代码的过程中,经常会遇到一些编译错误,其中重复定义函数参数就是其中之一。本文将详细介绍重复定义函数参数的原因和解决方案。什么是重复定义函数参数?在C++编程中,函数参数是指在函数定义和声明中出现的变量或表达式,用于接受函数调用时传递的实参。在定义函数的参数列表时,每个参数必须使用

函数参数传递方式与线程安全:值传递:创建参数副本,不影响原始值,通常线程安全。引用传递:传递地址,允许修改原始值,通常不线程安全。指针传递:传递指向地址的指针,类似引用传递,通常不线程安全。在多线程程序中,应慎用引用和指针传递,并采取措施防止数据竞争。

PHP函数参数类型包括标量类型(整数、浮点数、字符串、布尔值、空值)、复合类型(数组、对象)和特殊类型(回调函数、可变参数)。函数可自动转换不同类型参数,但也可通过类型声明强制特定类型,以防止意外转换并确保参数正确性。

在C++中选择函数参数传递方式时,有四种选择:按值传递、按引用传递、按指针传递和按const引用传递。按值传递创建参数值的副本,不会影响原始参数;按引用传递参数值的引用,可以修改原始参数;按指针传递参数值的指针,允许通过指针修改原始参数值;按const引用传递参数值的const引用,只能访问参数值,不能修改。

函数参数传递本质上决定了函数获取和修改外部变量的方式。在传值传递下,函数获得传入变量值的副本,对副本的修改不影响外部变量;在传引用传递下,函数直接接收外部变量的引用,对参数的修改也修改外部变量。

Python是一种高级编程语言,它与其他语言相比具有独特的特点。作为一种面向对象的语言,它能够提供丰富的库和模块,方便用户进行开发和编程。在Python中,函数是编写程序的基本单元,函数的参数可以根据需要进行传递。但是,在编写Python程序时,我们有时会遇到函数参数不足或过多的错误。这些错误可能会导致程序无法运行或结果不正确。为了避免这些错误,我们需要了解

C++是一种流行的编程语言,它被广泛应用于软件开发和系统编程中。C++编译器在解析源代码时,会检查代码的语法和语义,并生成可执行文件或库。当编译器遇到问题时,它会输出一定的错误信息,告诉程序员错误的具体位置和原因。本文将讨论一种常见的C++编译错误--错误的函数参数,并探讨如何修复它。一、错误信息示例下面是一个简单的C++程序,在编译时会出现错误的示例:#i

最新发布的PHP8版本带来了一些改进和新特性,其中namedarguments(命名参数)是一个新的功能,它使得函数的参数更加易读。在早期的PHP版本中,使用函数时需要按照定义的参数顺序依次传入每一个参数,这很容易导致混淆和错误。而namedarguments允许开发者为每个参数指定一个名字,然后无需按照顺序传入参数,在使用函数时可以指定参数名并传入相应


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
