xml出现EntityRef: expecting ';'错误

今天无意中生成xml出现EntityRef: expecting ';'错误,找了原因发现是含有&,url中的&应该写成&php中只需要写个函数

//去除转义字符
function transferHtml($content) {
$content=str_replace("<","<",$content);
$content=str_replace(">",">",$content);
$content=str_replace("&","",$content);
$content=str_replace(""",'"',$content);
$content=str_replace("'","'",$content);
$content=str_replace("/","/",$content);
$content=str_replace("“",'"',$content);
$content=str_replace("”",'"',$content);
$content=preg_replace("/&(.*?);/si","",$content); 
$content=str_replace("\\r","",$content);
$content=str_replace("\\n","",$content);
$content=str_replace("\\t","",$content);
$content=str_replace("\\","",$content);
return $content;
}

  这样就搞定了,演示:模块地图 (nongpin88.com)

 

posted @ 2023-11-05 21:12  圆柱模板  阅读(257)  评论(0编辑  收藏  举报