How to decompose html / php webpage?

Crazy question:

Imagine a webpage file called somepage.php and it contains some html php content in my editor that I see:

 <html><head></head><body> <?=$welcome . $essay . $thatsAllForNowFolks . $footer ?> <!-- Blue Ball Bell Blow Bows Bats Beef Bark Bill Boss --> </body></html> 

When I browse my site, I see these comments in the end result, while I want this comment to be only in my editor for my secret inspiration and not want the whole world to know what I think when I develop , just as I see those comments for all and all of my website visitors, like a lost internet speed bandwitch.

How can I decompose all html / php files at a time when html will be served? Ideas, code, and suggestions are greatly appreciated. I am grateful in advance ...

+4
source share
3 answers

Basically the same as Michiel's approach, but I'm lazy, so I would use shortened tags, just make sure short_open_tag is set to 1 in your php.ini configuration.

 <html><head></head><body> <?=$welcome . $essay . $thatsAllForNowFolks . $footer ?> <? /* Blue Ball Bell Blow Bows Bats Beef Bark Bill Boss */ ?> </body></html> 
+3
source

Probably the easiest solution is to write your comments in PHP. Thus, they will not be sent to the client in the source code. You can do it as follows:

 <html> <?php //A single comment /* Some more comments */ ?> </html> 
+14
source

It depends on the complexity of your pages / comments.

You can break them down using strpos and str_replace, or maybe regular expressions. But HTML is not an ordinary language, so the best way is to use the DOM parser to remove comments.

(You can register your function as an output filter in php using output buffering functions like ob_start)

+2
source

Source: https://habr.com/ru/post/1344103/


All Articles