- function dhtmlspecialchars($string, $flags = null) {
- if(is_array($string)) {
- //如果是数组。将用户数组划分为2维
- foreach($string as $key => $val) {
- $string[$key] = dhtmlspecialchars($val, $flags);
- // print_r($val);
- // exit;
- }
- } else {
- // echo 123;exit;
- if($flags === null) {
- //过滤特殊符号
- $string = str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $string);
- if(strpos($string, '&#') !== false) {
- $string = preg_replace('/&((#(/d{3,5}|x[a-fA-F0-9]{4}));)/', '&//1', $string);
- }
- } else {
- if(PHP_VERSION < '5.4.0') {
- $string = htmlspecialchars($string, $flags);
- } else {
- if(strtolower(CHARSET) == 'utf-8') {
- $charset = 'UTF-8';
- } else {
- $charset = 'ISO-8859-1';
- }
- $string = htmlspecialchars($string, $flags, $charset);
- }
- }
- }
- return $string;
- }
新闻热点
疑难解答