In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
In this issue, the editor will bring you about how to remove html comments from php. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Php to remove html comments: 1, open the corresponding PHP code file; 2, view the format of html comments; 3, through the "preg_replace (" / ",", $html); "method to remove html comments.
This article operating environment: windows7 system, PHP7.1 version, Dell G3 computer.
How does php remove html comments?
PHP filter html comments
Filter html comments:
The so-called filtering is nothing more than string matching and substitution. The regular matching substitution function preg_replace (reg,replace,string); PHPer is clear that the key to this function lies in the accuracy of reg, so let's give it a try:
The first thing to know is the format of html comments, which goes like this:.
Start regular writing
$html = "something"; $html = preg_replace ("/ /", "", $html); echo $html
The above code will output something. It seems to be a success. Don't worry, just test a few more examples.
$html = "something"; $html = preg_replace ("/ /", "", $html); echo $html
This example tells us that writing in this way does not achieve the desired effect, so the rule is optimized like this.
Preg_replace ("/", "", $html)
Well, that's satisfactory, but there's code like this in html, which is browser-compatible code that obviously can't be filtered, so our rule continues to optimize and look like this.
Preg_replace ("/", "", $html)
And then if there's code in html, we need to change our matching rules again, like this.
Preg_replace ("/", "", $html)
In that case, I basically get rid of the html comments I need to remove!
Windfall: in the optimization process, there are no many lines of comments to consider, but the rules unexpectedly match multiple lines of comments, I do not know if it is because of the html read from the file!
After testing, it has not been found that the text will be filtered out. If you have any questions, please leave a message for correction.
The above is the editor for you to share the php how to remove the html comments, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.