帝国cms自定义NOHTML函数标签过滤html代码用法
- 函数代码:
function NoHTML($string) { $string = preg_replace("'<script[^>]*?>.*?</script>'si", "", $string); $string = preg_replace("'<[\/\!]*?[^<>]*?>'si", "", $string); $string = preg_replace("'([\r\n])[\s]+'", "", $string); $string = mb_ereg_replace('^( | )+', '', $string); $string = mb_ereg_replace('( | )+$', '', $string); $string = preg_replace("'&(quot|#34);'i", "", $string); $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['你的字段'])?>