The interaction between PHP and html appears garbled
HTML part
If it is html, add in the head:
##
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
If it is html5:##
<meta charste="utf-8">
<?php
header("content-type:text/html;charset=utf-8");
?>
@$db = new mysqli($host, $user, $passwd)
$db->query("set names utf8");
$str = "测试"
$nes_str = iconv("gb2312", "UTF-8", $str) // gbk转utf8
The above is the detailed content of php loads html garbled code. For more information, please follow other related articles on the PHP Chinese website!