PHP头条
热点:

php变换html特殊符号


php 转换 html特殊符号
我写的函数

//转换某些特殊字符
function format_html($str){
$str = str_replace('“', '“',$str);
$str = str_replace('”', '”',$str);
$str = str_replace('·', '·',$str);
$str = str_replace('‘', '‘',$str);
$str = str_replace('’', '’',$str);
$str = str_replace('…', '…', $str);
$str = str_replace('—', '—', $str);
return $str;
}

但是这些符号实在是太多了。网上说的,大概255个。这么多,怎么可能转的完,有没有什么方法?

------解决方案--------------------
....亲不用这么转的 “ 这种符号当网页不识别html语言是就会这么显示 如果页面时full html的话 就是“

------解决方案--------------------
PHP code

htmlspecialchars :

$htm = "ab c";
echo htmlspecialchars($htm);
#源码
#ab c
#页面
#ab c

www.phpzy.comtrue/phprm/41164.htmlTechArticlephp变换html特殊符号 php 转换 html特殊符号 我写的函数 //转换某些特殊字符 function format_html($str){ $str = str_replace('', '“',$str); $str = str_replace('', '”',$str); $str = str_replace('', '',$str); $str = str...

相关文章

PHP之友评论

今天推荐