- php教程首页
- php函数
php符转换为HTML实体
•php函数•阅读 348 - function d_htmlspecialchars($string) {
- if(is_array($string)) {
- foreach($string as $key => $val) {
- $string[$key] = d_htmlspecialchars($val);
- }//开源代码phpfensi.com
- } else {
- $string = str_replace('&', '&', $string);
- $string = str_replace('"', '"', $string);
- $string = str_replace(''', ''', $string);
- $string = str_replace('<', '<', $string);
- $string = str_replace('>', '>', $string);
- $string = preg_replace('/&(#d;)/', '&1', $string);
- }
- return $string;
- }