您还可以从未显示的元素中过滤文本(内联样式= display:none)也就是说,如果html很简单,那么strip_tags可能会更快,并且可以完成相同的任务I am looking at getting the plain text from html. Which one should I choose, php strip_tags or simplehtmldom plaintext extraction?One pro for simplehtmldom is support of invalid html, is that sufficient in itself? 解决方案 You should probably use smiplehtmldom for the reason you mentioned and that strip_tags may also leave you non-text elements like javascript or css contained within script/style blocksYou would also be able to filter text from elements that aren't displayed (inline style=display:none)That said, if the html is simple enough, then strip_tags may be faster and will accomplish the same task 这篇关于php:从html获取纯文本-simplehtmldom或php strip_tags?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!