PHP | strip_tags로 제거 되지 않는 테그문제 | |||||
---|---|---|---|---|---|
작성자 | 작성일 | 18-03-07 20:44 | |||
strip_tags() 함수를 사용해서 테그를 제거려고 했더니 style이 정상적으로 제거 되지 않음... ㅎ ㅏ아.... 맨날 이러네.. 결국 검색으로 $content = preg_replace('~\<style(.*)\>(.*)\<\/style\>~', '', $content); echo strip_tags($content); 처리 했음... 그런데 문제가 어디서 복사를 해온건지...스크립트도 숨어 있음 function(b,d,c){if(b.getElementById(c)){return;}var a=b..... 이런식으로 된 문구는 테그가 안지워짐... function html2txt($document){ $search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA ); $text = preg_replace($search, '', $document); return $text; } $content = preg_replace('~\<style(.*)\>(.*)\<\/style\>~', '', $content); $content = html2txt($content); echo strip_tags($content); 로 해결... |
|||||
|
댓글목록
등록된 댓글이 없습니다.