PHP|strip_tags()の誤動作になりそうなタグを先に削除
スポンサーリンク
strip_tags()の誤動作になりそうなタグを先に削除
strip_tags()でHTMLタグを除去する前にjavascriptのコードなどが含まれていると誤動作になるので、あらかじめ除去しておくコードをメモ。
// strip_tags()の誤動作になりそうなタグを先に削除 $html = preg_replace('/<script.*?<\/script>/s', '', $html); $html = preg_replace('/<noscript.*?<\/noscript>/s', '', $html);
更新日:2018年10月26日
作成日:2018年10月26日