PHP文本转html
作者:admin 日期:2012-03-26
<?php
//文本转HTML
function Text2Html($txt)
{
$txt = str_replace(" "," ",$txt);
$txt = str_replace("<","<",$txt);
$txt = str_replace(">",">",$txt);
$txt = preg_replace("/[\r\n]{1,}/isU","<br/>\r\n",$txt);
return $txt;
}
$text='<h1>你好
世界!!!</h1>
';
echo Text2Html($text);
?>
代码运行示例:https://blog.guanjianci.net/codetest/php/TEXTtoHTML.php
评论: 0 | 引用: 0 | 查看次数: 2174
发表评论
广告位