用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'];?>以上是一个最简单的编辑器,可以加上很多其他功能。
<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'];?>以上是一个最简单的编辑器,可以加上很多其他功能。
$content = nl2br(trim($content));
$content = ereg_replace("\n ","\n ",$content);
$content = ereg_replace("'","''",$content)." ";
替换两个空格
<?php
$html = '测试 测试 测试 测试 <a href =" ">这是 链接</a>测试 测试 ';
$html = str_replace(" "," ",$html);
echo "$html<br>";
do {
$old = $html;
$html = preg_replace("/(.*<.+) (.*>.*)/U","\\1 \\2",$html);
}while($old != $html);
echo $html;
?>
$content=nl2br($content);
应该说是比较简单且好用的方法了