深正互联程序员告诉您简单快捷的php过滤html中script脚本的方法吧:
<?php
$html = <<<HTML
<a href="">asddasdffdf</a><div "f13">
www.lao8.org</div>
HTML;
$dom = new DOMDocument();
$dom->loadHTML($html);
$script = $dom->getElementsByTagName('script');
$remove = [];
foreach($script as $item)
{
$remove[] = $item;
}
foreach ($remove as $item)
{
$item->parentNode->removeChild($item);
}
$html = $dom->saveHTML();
echo $html;
?>
深圳 · 龙岗 · 大运软件小镇22栋201
电话:400 182 8580
邮箱:szhulian@qq.com