日期:2014-05-17  浏览次数:20459 次

很简单的一个页面、出现乱码
PHP code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<?php include("conn.php");
        if($_POST['sub'])
        {
            echo $_POST['urlname'];
        }
 ?>
 <form action="" method="post">
<div style="text-align:center">

<table>
    <tr>
        <td>链接名称:</td>
        <td><input type="text" name="urlname" /></td>
    </tr>
    <tr>
        <td>链接地址:</td>
        <td><input type="text" name="url" /></td>
    </tr>
    <tr><td></td><td><input type="submit" name="sbn" /></td></tr>
</table>

</div>
</form>
</body>
</html>




------解决方案--------------------
echo $_POST['urlname'];

出现乱码?

<?php
header('Content-Type: text/html; charset=utf-8');//添加此代码
------解决方案--------------------
你输入utf-8的数据不就行了。复制-粘贴到utf-8的界面。
------解决方案--------------------
不可能的!

除非你在浏览器上强制改变了编码