类似UBB代码的替换

      网页设计 2005-6-3 15:26
处理html语句的显示
在论坛等大文本的处理中,通常碰到无法回车或显示乱码,其实这是由于php在显示与文本框的显示不一致造成的,修改方法如下:
(1):用其他字符替换'
(2):用 回车 替换\r\n
$content= str_replace("'","mysinglequotes",$content);
$content=htmlspecialchars($content);
$content=nl2br($content);
然后把$content存入数据库即可。在显示时相反,用以下语句即可,
$content= str_replace("mysinglequotes","'",$content);
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}