for this php script,
$dom = new DOMDocument();
$dom->substituteEntities =FALSE;
$dom->loadHTML('<a href="$a?">$a</a>');
// print_r ($dom->getElementsByTagName("a")->item(0)->getAttribute("href"));
//the above statement show $a? correctly
echo $dom->saveHTML();
but it returned <a href="%24a">$a</a> to the browser when a saveHTML method was called. The $ in the href attribute was turned into %24 whereas the $ in the content of the a tag remains unchanged.
I expect the output is <a href="$a">$a</a> Is there any way to do this aside from the replace method?
By the way,
echo $dom->saveXML();
I get what I want with saveXML(); but together with an unexpected <!--xml...... Thanks
A safer approach in my case was to use:
$dom->saveXML();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With