Home >Web Front-end >Front-end Q&A >How to delete html comments

How to delete html comments

藏色散人
藏色散人Original
2021-04-12 10:43:274425browse

How to delete html comments: first open the corresponding code file; then delete the html comments through the "function remove_html_comments($content = ''){...}" method.

How to delete html comments

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 f80737884d6c93a4ecaeac0ca41583ac

b7eed15494c5e94925ac29cde8f7bece

  • You can use the following custom methods to delete useless comments:

function remove_html_comments($content = '') {
return preg_replace(&#39;/<!--(.|\s)*?-->/&#39;, &#39;&#39;, $content);
}

The input parameter is content, and preg_replace is regular replacement. , the rule is ed063da33f91bb19b178aaf57d56a83b

[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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn