How to delete html comments: first open the corresponding code file; then delete the html comments through the "function remove_html_comments($content = ''){...}" method.
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.
The content of the comments in the html can be deleted using regular expressions.
Generally the way to write HTML comments is
You can use the following custom methods to delete useless comments:
function remove_html_comments($content = '') { return preg_replace('/<!--(.|\s)*?-->/', '', $content); }
The input parameter is content, and preg_replace is regular replacement. , the rule is
[Recommended learning: HTML video tutorial]
The above is the detailed content of How to delete html comments. For more information, please follow other related articles on the PHP Chinese website!