<?php
$html_src = "
<!DOCTYPE html>
<html>
<body>
<a href=\"annimon.com\">goto home</a>
<script>
alert(\"Victor Protector doesn't work\");
</script>
<br>
<b>© aNNiMON</b>
<script>
alert(\"Victor Protector doesn't work твайс\");
</script>
</body>
</html>
";
echo "source is: " . $html_src;
$d = new DOMDocument;
$d->loadHTML($html_src);
$elements = $d->getElementsByTagName("script");
for ($i = $elements->length; --$i >= 0; ) {
$href = $elements->item($i);
$href->parentNode->removeChild($href);
}
$d->formatOutput = true; // красивый вывод
$html_clean = $d->saveHTML();
echo "\n\n filtered is:\n " . $html_clean;
PD9waHAKCiRodG1sX3NyYyA9ICIKPCFET0NUWVBFIGh0bWw+CjxodG1sPgoJPGJvZHk+CgkJPGEgaHJlZj1cImFubmltb24uY29tXCI+Z290byBob21lPC9hPgoJCTxzY3JpcHQ+CgkJCWFsZXJ0KFwiVmljdG9yIFByb3RlY3RvciBkb2Vzbid0IHdvcmtcIik7CgkJPC9zY3JpcHQ+CgkJPGJyPgoJCTxiPiZjb3B5OyBhTk5pTU9OPC9iPgoJCTxzY3JpcHQ+CgkJCWFsZXJ0KFwiVmljdG9yIFByb3RlY3RvciBkb2Vzbid0IHdvcmsg0YLQstCw0LnRgVwiKTsKCQk8L3NjcmlwdD4KCTwvYm9keT4KPC9odG1sPgoiOwoKZWNobyAic291cmNlIGlzOiAiIC4gJGh0bWxfc3JjOwoKCiRkID0gbmV3IERPTURvY3VtZW50OwokZC0+bG9hZEhUTUwoJGh0bWxfc3JjKTsKJGVsZW1lbnRzID0gJGQtPmdldEVsZW1lbnRzQnlUYWdOYW1lKCJzY3JpcHQiKTsKZm9yICgkaSA9ICRlbGVtZW50cy0+bGVuZ3RoOyAtLSRpID49IDA7ICkgewogICRocmVmID0gJGVsZW1lbnRzLT5pdGVtKCRpKTsKICAkaHJlZi0+cGFyZW50Tm9kZS0+cmVtb3ZlQ2hpbGQoJGhyZWYpOwp9CiRkLT5mb3JtYXRPdXRwdXQgPSB0cnVlOyAvLyDQutGA0LDRgdC40LLRi9C5INCy0YvQstC+0LQKJGh0bWxfY2xlYW4gPSAkZC0+c2F2ZUhUTUwoKTsKCmVjaG8gIlxuXG4gZmlsdGVyZWQgaXM6XG4gIiAuICRodG1sX2NsZWFuOw==