<html>
<head><title>my php</title></head>
<body>
<?php
header('Content-type: text/html; charset=utf-8');$myone="你好这是我第一个字符串连接";
$mytwo="的php程序文件";
$mythree="换行作用\n";
echo $myone.$mytwo.$mythree;
?>
</body>
</html>
这段程序运行的时候为什么显示乱码

解决方案 »

  1.   

    这样子试试<?php
    header('Content-type: text/html; charset=utf-8');
    ?><html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    <title>my php</title></head>
    <body>
    <?php$myone="你好这是我第一个字符串连接";
    $mytwo="的php程序文件";
    $mythree="换行作用\n";
    echo $myone.$mytwo.$mythree;
    ?>
    </body>
    </html>
      

  2.   

    看看浏览器编码,强制选择utf-8,或者自动检测
      

  3.   

    不一定额。如果他本身文件是gbk/gb2312的呢? 
    用eclipse,dw什么的打开文件查看页面编码是否是gbk/gb2312.如果是的话另存为utf-8编码的。
      

  4.   

    同样另存为utf-8编码的。 运行时还是显示的乱码
      

  5.   

    <html>
    <head><title>my php</title></head>
    <body>
    <?php
    header('Content-type: text/html; charset=gb2312');$myone="你好这是我第一个字符串连接";
    $mytwo="的php程序文件";
    $mythree="换行作用\n";
    echo $myone.$mytwo.$mythree;
    ?>
    </body>
    </html>
    ff检测通过  反正不是gb2312  就是utf-8