php中处理回车换行问题?##################### 我一般用iframe显示编辑数据库的内容,这样不用对回车换行进行特殊的处理,只要在读取数据库的时候将空白的符号替换成空就行了:) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 反转换function changestring($content){ $content = str_replace(""","\"",$content); $content = str_replace("<","<",$content); $content = str_replace(">",">",$content); $content = str_replace("&","&",$content); Return $content;} $target=nl2br(str_replace(" ",chr(127),htmlspecialchars($source)); 用$text=ereg_replace($text)echo"$text";就可以了...如果不行..就说... function txtToHtml($str){ $str = ereg_replace("&","&",$str); $str = ereg_replace("\"",""",$str); $str = ereg_replace("\'","'",$str); $str = ereg_replace("<","<",$str); $str = ereg_replace(">",">",$str); $str = ereg_replace("\r\n","<br>",$str); return $str;}function htmlToTxt($str){ $str = ereg_replace("&","&",$str); $str = ereg_replace(""","\"",$str); $str = ereg_replace("'","\'",$str); $str = ereg_replace("<","<",$str); $str = ereg_replace(">",">",$str); $str = ereg_replace("<br>","\r\n",$str); return $str;} $target=nl2br(str_replace(" ",chr(127),htmlspecialchars($source));注:我的这个方法是用于POST原始数据存入数据库的,因为这样才方便于以后再次调出来编辑。如果你的项目不是定死要先将内容转成 HTML 的话,建议按照我这个方法去做。这样的话,用户输入的东西跟显示出来是一摸一样的。 就你用这个.没问题的..兄弟..$text=ereg_replace($text)echo"$text";就可以了...如果不行..就EMAIL给我[email protected] nl2br(htmlspecialchars(addslashes("要存入数据库中的内容")));echo stripslashes("从数据库中取出的内容"); 如果以上都不是你要的,那么这个可能对你有用$content = str_replace(chr(13),"<br>",$content); str_replace("<br>","\r\n",$content); function txtToEnter($str){ $str = ereg_replace(" "," ",$str); $str = ereg_replace("\n","<br>",$str); return $str;}这个函数只在显示时用就可以了,这样用就行了txtToEnter(htmlspecialchars($Body)),一定好用,我用过!:) ThinkPHP 乱码问题 PHP很幼稚的问题 php如何连接远程my sql PHP中关于存储过程结果集的问题 [PHP,GIF]请大大指教下,这个想法是纯YY还是理论上能够实现的? 伙计做的动网论坛邮件地址收集工具,大家看有什么好的建议? 为什么我的php文件的变量传不到PHP??急!!急!!急!!急!!急!! $url= "show.php ?catid=".($row['catid']);请指点 PHP二分查找的疑惑 错误在哪啊?求大神帮助 php怎么处理复选select(不好意思,只有10分了,麻烦知道的进来看看) 求复投,投票系统只能投3个的代码
function changestring($content)
{
$content = str_replace(""","\"",$content);
$content = str_replace("<","<",$content);
$content = str_replace(">",">",$content);
$content = str_replace("&","&",$content);
Return $content;
}
echo"$text";就可以了...如果不行..就说...
{
$str = ereg_replace("&","&",$str);
$str = ereg_replace("\"",""",$str);
$str = ereg_replace("\'","'",$str);
$str = ereg_replace("<","<",$str);
$str = ereg_replace(">",">",$str);
$str = ereg_replace("\r\n","<br>",$str);
return $str;
}
function htmlToTxt($str)
{
$str = ereg_replace("&","&",$str);
$str = ereg_replace(""","\"",$str);
$str = ereg_replace("'","\'",$str);
$str = ereg_replace("<","<",$str);
$str = ereg_replace(">",">",$str);
$str = ereg_replace("<br>","\r\n",$str);
return $str;
}
echo"$text";就可以了...如果不行..就EMAIL给我[email protected]
{
$str = ereg_replace(" "," ",$str);
$str = ereg_replace("\n","<br>",$str);
return $str;
}
这个函数只在显示时用就可以了,这样用就行了txtToEnter(htmlspecialchars($Body)),一定好用,我用过!:)