关于Discuz!中dhtmlspecialchars函数的解析
- function dhtmlspecialchars($string) {
- if(is_array($string)) {
- foreach($string as $key => $val) {
- $string[$key] = dhtmlspecialchars($val);
- }
- } else {
- $string = str_replace(array('&', '"', '<', '>'),
- array('&', '"', '<', '>'), $string);
- if(strpos($string, '&#') !== false) {
- $string = preg_replace('/&((#(\d{3,5}|x[a-fA-F0-9]{4}));)/',
- '&\\1', $string);
- }
- }
- return $string;
- }