php 转换HTML代码函数示例

经测试代码如下:

/**
 * 转换HTML代码函数
 *
 * @param unknown_type $content
 * @param unknown_type $wrap 是否换行
 */
function htmlClean($content,$wrap = true) {
 $content = htmlspecialchars($content);
 if ($wrap) {
  $content = str_replace(\n,'<br />',$content);
 }
 $content = str_replace('  ','&nbsp;&nbsp;',$content);
 $content = str_replace(\t,'&nbsp;&nbsp;&nbsp;&nbsp;',$content);
 return $content;
}

/***   来自编程之家 jb51.cc(jb51.cc)   ***/

相关文章

文章浏览阅读8.4k次,点赞8次,收藏7次。SourceCodester Onl...
文章浏览阅读3.4k次,点赞46次,收藏51次。本文为大家介绍在...
文章浏览阅读1.1k次。- php是最优秀, 最原生的模板语言, 替代...
文章浏览阅读1.1k次,点赞18次,收藏15次。整理K8s网络相关笔...
文章浏览阅读1.2k次,点赞22次,收藏19次。此网络模型提供了...
文章浏览阅读1.1k次,点赞14次,收藏19次。当我们谈论网络安...