我一运行你的第一个文件,竟然出来这么多错误,你是让我们改错吗
<br />
<b>Notice</b>:  Undefined variable:  filename in <b>/home/yjj/public_html/test/index.php</b> on line <b>2</b><br />
<br />
<b>Warning</b>:  fopen("", "r") - Inappropriate ioctl for device in <b>/home/yjj/public_html/test/index.php</b> on line <b>2</b><br />
<br />
<b>Notice</b>:  Undefined variable:  filename in <b>/home/yjj/public_html/test/index.php</b> on line <b>3</b><br />
<br />
<b>Warning</b>:  stat failed for  (errno=2 - No such file or directory) in <b>/home/yjj/public_html/test/index.php</b> on line <b>3</b><br />
<br />
<b>Warning</b>:  fread(): supplied argument is not a valid File-Handle resource in <b>/home/yjj/public_html/test/index.php</b> on line <b>3</b><br />
<br />
<b>Warning</b>:  fclose(): supplied argument is not a valid File-Handle resource in <b>/home/yjj/public_html/test/index.php</b> on line <b>4</b><br />
<html>
<head>
  <title>编辑php文件代码</title>
</head>
<body bgcolor="fafad2">
您正在修改的文件是:
<font size=4 color="blue">
<br />
<b>Notice</b>:  Undefined variable:  filename in <b>/home/yjj/public_html/test/index.php</b> on line <b>14</b><br />
</font>
<center>
<form action="edit2.php" method="post">
  <input type="hidden" name="filename" value="<br />
<b>Notice</b>:  Undefined variable:  filename in <b>/home/yjj/public_html/test/index.php</b> on line <b>18</b><br />
">
  <textarea name="content" rows=22 cols=100>  </textarea><br><br>
  <input type="submit" value="保存">&nbsp;&nbsp;
  <input type="button" value="返回" onclick="javascript:history.back();">
</form>
</center>
</body>
</html>

解决方案 »

  1.   

    你的意思是不是这样
    <?php
    $str = "<hr>";
    print $str;
    print htmlentities($str);
      

  2.   

    xizi2002(☆☆戏☆子☆☆) :
    htmlentities()是什么函数啊,现在可以了,但是汉字却显示成乱码了
      

  3.   

    用htmlentities函数处理一下即可
      

  4.   

    $str=fread($fp,filesize($filename));
    换成
    $str=htmlspecialchars(fread($fp,filesize($filename)));或者:读的时候
    $str=str_replace("</textarea>","[/textarea]",fread($fp,filesize($filename)));存的时候
    $str=str_replace("[/textarea]","</textarea>",$willbe_save_filedata);
      

  5.   

    我上面已经说了,可以显示</textarea>之后的内容了,但就是汉字显示成了乱码,怎么在能显示出正确的汉字呢?谢谢
      

  6.   

    使用函数:strip_tags()去除html和php的标记即可。
      

  7.   

    strip_tags()是什么函数啊,我怎么没查到,可以把汉字显示出来吗,怎么用它?多谢!
      

  8.   

    strip_tags(),可去掉字串中包含的任何 HTML 及 PHP 的标记字串。若是字串的 HTML 及 PHP 标签原来就有错,例如少了大于的符号,则也会传回错误。而本函式和 fgetss() 有着相同的功能
      

  9.   

    用strip_tags()来去除HTML 及 PHP 的标记字串,但是我依然要显示这些标记呀,这么说吧,
    我是想在文本框里显示PHP文件代码,而现在的遇到的问题是汉字显示成了乱码。我该怎么做。