我想你要的是htmlspecialchars()函数吧。。

解决方案 »

  1.   

    我的意思是说,有没有一种函数能将上面的1.html 的文件的内容转化为字符串,
    如果没有的话,能否提示一下怎么解决??
      

  2.   

    <?php
    $str = implode("\n", file("1.htm"));
    ?>
      

  3.   

    file_get_content
    这个在php4.3 以后才行吧
    我的是 php4.2 
      

  4.   

    还有我想要的是 那个字符串$str="<html><body><input name=user $user$></body></html>"而<html><body><input name=user $user$></body></html>  则是1.html 的原文件不知道我说的意思大家明白了没?
      

  5.   

    function html_clean($content) {
      $content = htmlspecialchars($content);
      $content = str_replace("\n", "<br />", $content);
      $content = str_replace("  ", "&nbsp;&nbsp;", $content);
      $content = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $content);
      return $content;
    }这个就可以了,看看是不是你要的!
      

  6.   

    多谢各位
    我的意思大家可能还不明白。
    但是我已经知道了我把我想要的结果说出来吧,你们运行一下就明白我的意思了首先 是1.html<html>
    <body>
    name:<input name=user $user$>
    </body>
    </html>然后是 2.php
    <?
    $str = implode("\n", file("1.html"));
    $content = str_replace("$user$", "value=\"me\"", $str);
    echo $content; 
    ?>
    运行2.php
    我想要的就是这个意思,明白了吧 。再此多谢各位好心的帮助。
    感谢   spacet(空格t)   和 caotian2000() 这下大家的意思应该明白了吧。
    当然还有其他的解决方法。 能否说来听听
      

  7.   

    <?php
    // get contents of a file into a string
    $filename = "/usr/local/something.txt";
    $handle = fopen($filename, "r");
    $contents = fread($handle, filesize ($filename));
    fclose($handle);
    $content = str_replace("$user$", "value=\"me\"", $str);
    echo $content; 
    ?>
      

  8.   

    $string = file_get_content($url)
      

  9.   

    to wuyz124(玖头鸟) 的确,我这样做的意思就是表达 使用模板。我自己这么想用这种方法来实现引用模板。你所说的模板指的是什么??能否详细介绍?