转义html标签并只读取php中的文本?

get*_*way 1 html php escaping

我想知道有没有办法从一堆html代码中逃避所有html标签,并只提取文本即

<strong>this is strong</strong>
<br />
<h1> this is a header</h1>
Run Code Online (Sandbox Code Playgroud)

我想只在标签之间获取文本,所以基本上只是 this is strong this is a header

cli*_*fin 9

$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
Run Code Online (Sandbox Code Playgroud)

我喜欢PHP的一个方面... Web开发人员的深思熟虑的功能.