Is there a way to hide commenting in my php/html file?
I want to add markup that I don't want people to be able to view in source in their browsers.
Is this possible?
<!-- Prevent this comment from being viewed -->
<开发者_StackOverflow社区?php...
Thanks in advance.
If you add comments as PHP, people won't see it in their browser.
<div> 
   <!-- This HTML comment can be seen by people -->
   <?php //But this PHP comment can only be seen by me :) ?>
</div>
http://en.wikipedia.org/wiki/PHP
I see what you mean. You can do that with output buffering:
<?php
   // this is not
?><!-- this is sent to browser -->
And with output buffering.
<?php
   ob_start();
   ?><!-- this is NOT sent to browser --> <b>This isn't sent as well!</b> <?php
   ob_end_clean();
?>
However, if you want to remove comments only, you need to do some parsing:
<?php
   ob_start();
   ?><!-- this is NOT sent to browser --><?php
   $html=ob_get_clean();
   // TODO: Use a DOM parser to parse $html and remove comments from it.
?>
That does sound a bit over-engineered though...
Just swap lines above and use php comment:
<?php...
// Prevented this comment from being viewed
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论