strip_tags() in PHP has several problems. strip_tags () in PHP ha diversi problemi. It doesn’t recognize that css within the style tags are not document text. Non riconoscere che nel css stile tag non sono documento di testo. It will not remove HTML entities or content within script tags. Esso non rimuovere le entità HTML o contenuto all'interno di tag di script. strip_tags() fails for invalid HTML. strip_tags () non valido per non HTML. In short strip_tags() is not advisable to use except for trivial cases. In breve strip_tags () non è consigliabile usare fatta eccezione per i casi banali. The best solution I have come across is by uersoy at tnn dot net: La soluzione migliore Sono venuto è tutta da uersoy a TNN dot net:

 function html2txt($document){   $search = array('@ funzione html2txt ($ documento) ($ search = array ( '@  ]*?>.*? ]*?>.*?  @si',  // Strip out javascript                  '@ se @ ', / / Striscia di javascript' @  ]*?>.*? ]*?>.*?  @siU',    // Strip style tags properly                  '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags                  '@ Siu @ ', / / Striscia di stile correttamente i tag' @ <[\ / \ !]*?[^<>]*?>si ', / / Strip out HTML tags' @  @'         // Strip multi-line comments including CDATA   );   $text = preg_replace($search, '', $document);   return $text; } @ '/ / Striscia di multi-linea CDATA commenti compresi); $ testo = preg_replace ($ ricerca,'', $ documento); return $ testo;)