strip_tags(html)
Strips all HTML tags from the html, including comments. This uses the html-scanner tokenizer and so its HTML parsing ability is limited by that of html-scanner.
strip_tags("Strip <i>these</i> tags!")
# => Strip these tags!
strip_tags("<b>Bold</b> no more! <a href='more.html'>See more here</a>...")
# => Bold no more! See more here...
strip_tags("<div id='top-bar'>Welcome to my website!</div>")
# => Welcome to my website!
本文介绍了一种在HTML中移除所有标签包括注释的方法,利用html-scanner解析器进行操作。通过示例展示了如何去除不同类型的HTML标签,如斜体、加粗、链接及带有属性的div标签。
447

被折叠的 条评论
为什么被折叠?



