Heim > Artikel > Backend-Entwicklung > php 符转换为 HTML 实体_PHP教程
php教程 符转换为 html 实体
function d_htmlspecialchars($string) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = d_htmlspecialchars($val);
}
} else {
$string = str_replace('&', '&', $string);
$string = str_replace('"', '"', $string);
$string = str_replace(''', ''', $string);
$string = str_replace(' $string = preg_replace('/&(#d;)/', '&1', $string);
}
return $string;
}