Reputation: 21
Just the part that confuses me:
<?php
echo "Start\n";
$newdoc = new DOMDocument();
$newdoc->loadHTML("<script>document.write('</scr' + 'ipt>');</script>");
echo $newdoc->saveHTML();
echo "\nDone\n";
It will output:
<script>document.write('' + 'ipt>');</script>
Why does it do that and how can I avoid it?
Upvotes: 2
Views: 244
Reputation: 9749
You have to escape the slash:
$newdoc->loadHTML("<script>document.write('<\/scr' + 'ipt>');</script>");
Upvotes: 1