翻过高山走不出你
使用PHP DOMDocument解析器。$doc = new DOMDocument();// load the HTML string we want to strip$doc->loadHTML($html);// get all the script tags$script_tags = $doc->getElementsByTagName('script');$length = $script_tags->length;// for each tag, remove it from the DOMfor ($i = 0; $i
$script_tags->item($i)->parentNode->removeChild($script_tags->item($i));}// get the HTML string back$no_script_html_string = $doc->saveHTML();这让我使用以下HTML文档:nbsp;html>
hey
alert("hello");
hey 请记住,DOMDocument解析器需要PHP 5或更高版本。