strip_tags() in PHP has several problems. strip_tags ( )のはPHPにはいくつかの問題が発生します。 It doesn’t recognize that css within the style tags are not document text.わけではないと認識していないのCSSにタグは、ドキュメントのテキストのスタイルです。 It will not remove HTML entities or content within script tags.削除することはありませんHTMLエンティティまたはコンテンツにscriptタグです。 strip_tags() fails for invalid HTML. strip_tags ( )の失敗した場合は、無効なhtmlに変更します。 In short strip_tags() is not advisable to use except for trivial cases.端的にstrip_tags ( )のではないささいお勧めいたしませんを使用する場合を除いています。 The best solution I have come across is by uersoy at tnn dot net:私は、最善の解決策はuersoyはTNNケースに出くわすドットネット:

 function html2txt($document){   $search = array('@ 関数html2txt ( $ドキュメント) ( $検索=アレイ( ' @  ]*?>.*? ]*?>.*?  @si',  // Strip out javascript                  '@ @ si ' 、 / /ストリップアウトのJavaScript ' @  ]*?>.*? ]*?>.*?  @siU',    // Strip style tags properly                  '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags                  '@ @シウ' 、 / /ストリップスタイルのタグを正しく' @ < [ \ / \ !]*?[^<>]*?>@ si ' 、 / /ストリップアウトHTMLタグ' @  @'         // Strip multi-line comments including CDATA   );   $text = preg_replace($search, '', $document);   return $text; } @ ' / /ストリップのCDATA複数行のコメントを含む) ; $テキスト= preg_replace ( $検索、 '' 、 $ドキュメント) ;返す$テキスト; )