不多BB,直接上菜
<?php
header("content-type:text/html;charset=utf-8");
//声明编码为UTF-8(通用编码)
//此段需放在代码顶部
?>
如果是类似这种代码混编(php/html均自带utf-8编码声明)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
<?php
header("content-type:text/html;charset=utf-8");
?>
则需要加
HTML加:<meta charset="utf-8">
PHP加:header("content-type:text/html;charset=utf-8");