Home > Backend Development > PHP Tutorial > 各大神帮帮忙,怎么解决这个乱码问题

各大神帮帮忙,怎么解决这个乱码问题

WBOY
Release: 2016-06-23 13:44:42
Original
904 people have browsed it

这是前面部分
header("Content-Type:text/html;charset=utf-8");
?>

<script></script>

<script> <br /> function show(username){ <br /> if(username==""){ <br /> alert("用户名不能为空"); <br /> return; <br /> } <br /> var ajax=Ajax(); <br /> var userobj=document.getElementById("userid"); <br /> ajax.post("form.php",{username:username},function(data){ <br /> userobj.innerHTML=data; <br /> }); <br /> } <br /> </script>


username:

password:


这是模拟服务器部分

header("Content-Type:text/html;charset=utf-8");

$mysqli=new mysqli("localhost","root","123456","web");

$result=$mysqli->query("select * from user where user='{$_POST["username"]}'");

if($result->num_rows > 0){
echo "用户{$_POST["username"]}已经存在,不能使用";
}else{
echo "用户{$_POST["username"]}不存在,可以使用";
}

在浏览器出现中文乱码,怎么解决呀,,,,,谢谢各位大神帮帮忙!!!!


回复讨论(解决方案)

你的服务端文件不是utf-8编码。改成utf-8编码应该就可以了。

看看你的PHP脚本文件编码格式必须是utf8才行呢

怎么设置服务端的编码?

用编辑器保存为utf-8 无BOM头格式。

应该是bom头导致的

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template