Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decomment an html/php webpage?

A crazy question:

Imagine a webpage file called somepage.php And it contains some html php contents in my editor 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 those comments in the final result, while I only want that comment to be only in my editor for my secretive inspirations and don't want the whole world to know what I'm thinking when I'm developing, as well as I see those comments for any and all my website visitors as wasted bandwitch of internet speed.

How do I decomment my entire html/php files at the moment the html is served? Ideas, code and suggestions are much appreciated. My thanks in advance...

like image 887
Sam Avatar asked Dec 02 '22 03:12

Sam


2 Answers

Probably the easiest solution is to write your comments in PHP. This way they will not be sent to the client in the source code. You can do it like this:

<html>

<?php
    //A single comment

    /*
         Some more
         comments
    */
?>

</html>
like image 52
Michiel Pater Avatar answered Dec 04 '22 11:12

Michiel Pater


Basically the same as Michiel's approach but I'm lazy so I would use the abbreviated tags, just be sure you have short_open_tag set to 1 in your php.ini config.

<html><head></head><body>  
<?=$welcome . $essay . $thatsAllForNowFolks . $footer ?>

<? /*
Blue
Ball
Bell
Blow
Bows
Bats
Beef
Bark
Bill
Boss

*/ ?>
</body></html>
like image 40
esdot Avatar answered Dec 04 '22 12:12

esdot