UTF-8 not working in HTML forms(UTF-8 在 HTML 表单中不起作用)
问题描述
我有这个表格:
<form method="post" enctype="multipart/form-data" accept-charset="UTF-8">
但是当我提交 é 字符时,它会变成 é.
But when I submit an é character, it turns it into é.
为什么这不起作用?是的,MySQL 数据库已正确设置所有字符集.(数据库,表格.)如果我用 Navicat 手动将它放入数据库,它会在网页上正常显示.
Why doesn't this work? Yes, the MySQL database has all the character-sets set up correctly. (Database, tables.) If I manually put it in the database with Navicat it shows up fine on the webpage.
另外,我尝试了元标记,设置了内容类型标头,但没有成功.
Also, I have tried the metatag, setting the content-type header, without success.
推荐答案
在你的 HTML 中,添加这个元标记:
In your HTML, add this meta tag:
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
还要在脚本顶部添加此 PHP 标头:
Also add this PHP header at top of the script:
header("Content-Type: text/html;charset=UTF-8");
:
另外一个技巧是将文件保存为 UTF-8 without BOM
编码.您可以使用 Notepad++ 或任何不错的编辑器来执行此操作.
One more tip is to save the file as UTF-8 without BOM
encoding. You can use Notepad++ or any decent editor to do that.
这篇关于UTF-8 在 HTML 表单中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UTF-8 在 HTML 表单中不起作用


- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01