函数代码如下:

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 中,这里是存储用户的自定义函数。

接下来在内容页描述的meta标签中调用如下标签:

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

注意外层一定要包裹我们写的自定义函数,这样就可以实现无特殊格式的输出smalltext简介字段了。

历史上的今天
12月
16
    抱歉,历史上的今天作者很懒,什么都没写!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。