时间:2021-07-01 10:21:17 帮助过:17人阅读
1. 纯文本输出,适合input
function t($text){ $text = h($text); $text = strip_tags($text); return $text; }
2. 多行纯文本 适合textarea
function text($text) { return trim(nl2br(str_replace(' ', ' ', htmlspecialchars($text)))); }
3. 将html换行变成回车
function br2nl($text) { return trim(preg_replace('/
/i', '', $text)); }
4. 输出安全的html
function h($text){ $text = trim($text); $text = stripslashes($text); //完全过滤注释 $text = preg_replace('//','',$text); //完全过滤动态代码 $text = preg_replace('/<\?|\?'.'>/','',$text); //完全过滤js $text = preg_replace('/