PHP解码方括号href attr到html文件

PHP解码方括号href attr到html文件,php,Php,保存html将解码方括号 //My STRing $teaserTest = "<a href='[CLICK_URL]'><strong>testgerr</strong></a>"; //Calling save function saveFile($teaserTest); //Save function function saveFile($stringToAdd){ $doc = new DOMDocument(); $

保存html将解码方括号

//My STRing     
$teaserTest = "<a href='[CLICK_URL]'><strong>testgerr</strong></a>";
//Calling save function
saveFile($teaserTest);    
//Save function
function saveFile($stringToAdd){
$doc = new DOMDocument();
$doc->formatOutput = true;
$doc->loadHTML('<html><head><title>Test</title></head><body>'.$stringToAdd.'</body></html>');

$doc->saveHTMLFile("Campaigns/test.html");
}
//我的字符串
$STREARTEST=“”;
//调用save函数
保存文件($strisertest);
//保存功能
函数保存文件($stringToAdd){
$doc=新的DOMDocument();
$doc->formatOutput=true;
$doc->loadHTML('Test'.$stringToAdd'.');
$doc->saveHTMLFile(“活动/test.html”);
}
文件重新结果

我正在努力让“[”解码

在下面的示例中指定,这对于
示例的ip地址很重要:http://[::1]/example/


这是因为编码很好。但是如果您有一种特殊的方法,请使用不同的模式。

您可能需要尝试
loadHtml($yourHtmlString,LIBXML\u NOENT)
——这应该停止替换某些实体。
[]  brackets are special chars in url