如何在PHP中将收到的http变量的字符集设置为UTF-8? [英] How to set the charset to UTF-8 for a received http variable in PHP?

查看:131
本文介绍了如何在PHP中将收到的http变量的字符集设置为UTF-8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为PHP中接收到的http变量将字符集设置为UTF-8?

How to set the charset to UTF-8 for a received http variable in PHP?

我使用 POST 具有1个输入字段的方法。但是,当我提交表单并通过 $ _ POST ['input_name'] 回显从输入字段中检索到的内容时,我得到了:KrkiÄ-但我输入了(我需要):Krkič

I have a html form using the POST methode with 1 input field. But when i submit the form and echo the retrieved the contents from the input field via $_POST['input_name'] i get this: KrkiÄ - but i entered (and i need) this: Krkič

那么我该如何解决呢?

我现在想通了。 :)

如果我要将内容添加到MYSQL,则需要添加以下内容:

If i want to add the contents to MYSQL then i need to add this:

if(!$mysqli->set_charset("utf8")){
printf("Error loading character set utf8: %s\n",$mysqli->error);
}

如果我只需要回显内容,则添加此元标记

If i just need to echo the contents then adding this meta tag

<meta charset="utf-8">

插入html head就足够了。

into html head is enough.

推荐答案

您可以使用:

<meta charset="UTF-8" />

这篇关于如何在PHP中将收到的http变量的字符集设置为UTF-8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆