<nav class="xqlj mt15"> <div class="spxq"><img src="1.jpg" width="1200" style="max-width:90%" alt="" border="0" /><iframe src="http://www.tudou.com/programs/view/html5embed.action?type=1&code=vZ00D1Xubu4&lcode=q711Bs57_Nw&resourceId=0_06_05_99" allowtransparency="true" allowfullscreen="true" allowfullscreeninteractive="true" scrolling="no" border="0" frameborder="0" style="width:1200px;height:500px;"></iframe></div> </nav>
有两个width和height,你要去掉哪个?
参考: http://blog.csdn.net/fdipzone/article/details/11884285
require('HtmlAttributeFilter.class.php');$str = '<nav class="xqlj mt15"> <div class="spxq"><img src="1.jpg" width="1200" style="max-width:90%" alt="" border="0" /><iframe src="http://www.tudou.com/programs/view/html5embed.action?type=1&code=vZ00D1Xubu4&lcode=q711Bs57_Nw&resourceId=0_06_05_99" allowtransparency="true" allowfullscreen="true" allowfullscreeninteractive="true" scrolling="no" border="0" frameborder="0" style="width:1200px;height:500px;"></iframe></div> </nav>';$obj = new HtmlAttributeFilter();// 允许id属性$obj->setAllow(array('src','alt','border'));$obj->setException(array());// img 标签忽略,不过滤任何属性$obj->setIgnore(array('nav','div','iframe'));echo 'source str:
';echo htmlspecialchars($str).'
';echo 'filter str:
';echo htmlspecialchars($obj->strip($str));
有两个width和height,你要去掉哪个?
都去掉谢谢大家的热心回答