保存一个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");
}
文件资源<a href="%5BCLICK_URL%5D">
我试图保持"["解码。
[] brackets are special chars in url
在以下 RFC 中指定 对于 IP 地址很重要example: http://[::1]/example/
那是因为它很好编码。但是,如果您有特殊方法,请使用不同的模式。