<?php
$file = fopen("liuyan.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
while(!feof($file))
  {
  echo fgets($file);
 }
 
fclose($file);
?>为什么输出来的内容是乱码,要怎么解决呀,急啊?

解决方案 »

  1.   

    文件编码和页面编码不一致
    用iconv转码试一下
      

  2.   

    这个问题,应该有n个帖子说了嘛?首先你php文件的编码要和txt统一,输出的时候header("charset=?")红色部分是http头,你可以查下资料..
    还是搜别人的帖子吧.
      

  3.   

    中文?<?php
    $file = fopen("liuyan.txt", "r") or exit("Unable to open file!");
    //Output a line of the file until the end is reached
    while(!feof($file)){
      $string .= fgets($file);
    }
    fclose($file);
    $chinese = iconv('ISO-8859-1', 'GB2312', $string);
    echo $chinese;
    ?>