php对表单内容进行处理
/** * 过滤HTML内容后返回 * * @param $string * @param bool $html * * @return array|string */ public static function safeOutput($string, $html = false) { if (!$html) $string = strip_tags($string); return @Tools::htmlentitiesUTF8($string, ENT_QUOTES); } public static function htmlentitiesUTF8($string, $type = ENT_QUOTES) { if (is_array($string)) return array_map(array('Tools', 'htmlentitiesUTF8'), $string); return htmlentities((string)$string, $type, 'utf-8'); } public static function htmlentitiesDecodeUTF8($string) { if (is_array($string)) return array_map(array('Tools', 'htmlentitiesDecodeUTF8'), $string); return html_entity_decode((string)$string, ENT_QUOTES, 'utf-8'); } /** * 对POST内容进行处理 * * @return array */ public static function safePostVars() { if (!is_array($_POST)) return array(); $_POST = array_map(array('Tools', 'htmlentitiesUTF8'), $_POST); }
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号