# 如何在帝国cms的内容页输出不换行且没有特殊字符的内容简介

*Published:* 2023-12-16
*Author:* 客服001

#### 温馨提醒

如果文章内容或图片资源失效，请留言反馈，我们会及时处理，谢谢

本文最后更新于2023年12月16日，已超过 180天没有更新



[函数](https://www.xarjtc.com/tag/%e5%87%bd%e6%95%b0 "查看函数此标签更多文章")代码如下：

```
function Cmsdx_format_html($str){  
$str=trim($str);  
$str=str_replace('&','',$str);  
$str=str_replace('ldquo;','“',$str);  
$str=str_replace('rdquo;','”',$str);  
$str=str_replace('middot;','·',$str);  
$str=str_replace('lsquo;','‘',$str);  
$str=str_replace('rsquo;','’',$str);  
$str=str_replace('hellip;','…',$str);  
$str=str_replace('mdash;','—',$str);  
$str=str_replace('ensp;','',$str);  
$str=str_replace('emsp;','',$str);  
$str=str_replace('nbsp;','',$str);  
$str=str_replace(' ','',$str);  
$str=str_replace('t','',$str);    
$str=str_replace('rn','',$str);    
$str=str_replace('r','',$str);    
$str=str_replace('n','',$str);    
$str=str_replace(' ','',$str);  
$str = preg_replace('/s(?=s)/','', $str);// 接着去掉两个空格以上的  
$str = preg_replace('/[nrt]/',' ', $str);// 最后将非空格替换为一个空格  
return trim($str);  
}
```

我们将上述函数放到 /e/class/userfun.php 中，这里是存储用户的自定义函数。

接下来在[内容页](https://www.xarjtc.com/tag/%e5%86%85%e5%ae%b9%e9%a1%b5 "查看内容页此标签更多文章")描述的meta标签中调用如下标签：

```
<?=Cmsdx_format_html($navinfor['smalltext'])?>
```

注意外层一定要包裹我们写的自定义函数，这样就可以实现无特殊格式的输出smalltext[简介](https://www.xarjtc.com/tag/%e7%ae%80%e4%bb%8b "查看简介此标签更多文章")字段了。