用html编辑器来实现。<post.htm><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language="javascript">
function initEditor(Model) {
Editor.document.designMode=Model;
Editor.document.open();
initHTML = "";
Editor.document.write(initHTML);
Editor.document.close();
}
function posts(){
var msg=Editor.document.body.innerHTML;
form1.content.value=msg;
}
</script>
</HEAD>
<BODY onload="initEditor('ON');">
<form method="POST" action="get.php" name=form1 onsubmit="posts();">
<iframe id="Editor" Name="Editor" style="width: 100%; height: 300px ;leftmargin:0 ;topmargin:0" ></iframe>
  <p><input type="hidden" name="content" size="20"></p>
  <p><input type="submit" value="按钮" name="B1"></p>
</form>
</BODY>
</HTML><get.php><?php
/**
* 程序编写:偶然
* 编写时间:2003.7
* 本页说明:取得传入数据
*/echo $_POST['content'];?>以上是一个最简单的编辑器,可以加上很多其他功能。

解决方案 »

  1.   

    $content  =  ereg_replace(" ","&nbsp;",$html);
    $content  =  nl2br(trim($content));
    $content  =  ereg_replace("\n  ","\n  ",$content);
    $content  =  ereg_replace("'","''",$content)." ";
      

  2.   

    $Tmp=str_replace("  ","&nbsp;&nbsp;",$Tmp);
    替换两个空格
      

  3.   

    转换以后再有选择的换回来
    <?php
    $html = '测试 测试 测试 测试 <a href =" ">这是 链接</a>测试 测试 ';
    $html = str_replace(" ","&nbsp;",$html);
    echo "$html<br>";
    do {
      $old = $html;
      $html = preg_replace("/(.*<.+)&nbsp;(.*>.*)/U","\\1 \\2",$html);
    }while($old != $html);
    echo $html;
    ?>
      

  4.   

    $content=htmlspecialchars($content);
    $content=nl2br($content);
    应该说是比较简单且好用的方法了
      

  5.   

    但如果要输出HTML文档的连接,那就做很多处理!