帝国cms过滤特定的字符函数,多用于简介地方,把函数放在“/e/class/connect.php”最后面,当然你只对前台过滤也可以放在“/e/class/userfun.php”里面,我由于要对整个系统二次开发所以放在connect后面,前后台都可以使用。

//去除HTML标记

function NoHTML($string){

$string = preg_replace("''si", "", $string);//去掉javascript

$string = preg_replace("']*?>'si", "", $string); //去掉HTML标记

$string = preg_replace("'([\r\n])[\s]+'", "", $string); //去掉空白字符

$string = mb_ereg_replace('^( | )+', '', $string);

$string = mb_ereg_replace('( | )+$', '', $string);

$string = preg_replace("'&(quot|#34);'i", "", $string); //替换HTML实体

$string = preg_replace("'&(amp|#38);'i", "", $string);

$string = preg_replace("'&(lt|#60);'i", "", $string);

$string = preg_replace("'&(gt|#62);'i", "", $string);

$string = preg_replace("'&(nbsp|#160);'i", "", $string);

return $string;

}

用法:

=NOHTML($navinfo['你的字段'])?> ad51e517755f8fd6a7ec83ced4ecfaf3.png

原文链接:https://blog.csdn.net/weixin_36330888/article/details/118139721?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522166669233216782412554393%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=166669233216782412554393&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-7-118139721-null-null.article_score_rank_blog&utm_term=%E5%B8%9D%E5%9B%BDcms

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注