I’m trying to append some HTML to the end of the body with PHP. I’m using a DOMText object and appending it like so:
$js = new DOMText("<script type='text/javascript'>\njson='".$response."';alert(json);</script>");
$bodyTags = $indexDOM->getElementsByTagName('body');
$bodyTags->item(0)->appendChild($js);
The problem is that the HTML I’m appending is being surrounded by quotation marks. Is there any way to remove those quotation marks or an alternative way that doesn’t surround the text with quotes?
I guess you should be using
DOMNodehttp://www.php.net/manual/en/class.domnode.php orDOMElementhttp://www.php.net/manual/en/class.domelement.phpto get the job done.
EDIT
Example:
There are several ways of achieving this. this is just an example.