How to delete html comments

藏色散人
Release: 2023-01-04 09:36:02
Original
4393 people have browsed it

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

  • 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);
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template