...

View Full Version : comment tag not working



ketanco
11-26-2009, 12:55 AM
Hello,


<li class="first <? if(is_home()) echo 'current_page_item'; ?>"><a href="<?php echo get_option('home'); ?>/">Home</a></li>

I was trying to put the whole thing in a comment, so that I could test the file without this code being there. So I put comment tags before and after the whole thing:



<!--
<li class="first <? if(is_home()) echo 'current_page_item'; ?>"><a href="<?php echo get_option('home'); ?>/">Home</a></li>
-->

However, it is not including everything within the comment as a comment. Why is that? I mean I thought everything with the <!-- and --> would be totally omitted as a comment. But it is not. Why?

Cisneiros
11-26-2009, 12:59 AM
If there is PHP code inside a <!-- comment -->, it will still be processed, so if you have something like:

<!-- <li><? echo $name; ?></li> -->The expected behaviour is something like:

<!-- <li>John Doe</li> -->The PHP code will be "commented" on the HTML and won't show up on the screen, but it will be processed.

ketanco
11-26-2009, 01:03 AM
so as far as seeing the output i will not see it, but if the php is doing something else than echoing something or giving some output, that will be processed, so if it is something affecting other portion of the site, it still can right? so in order to absolutely disable what that php does there, I either have to put a php comment like // into php, or i should delete the whole line of code, am I right?

Cisneiros
11-26-2009, 01:07 AM
Yes, you are.
<!-- comments --> just hide it's content from the User's screen, but PHP does not care if it will show up or not. To stop PHP from processing code, you must comment your code with // comments or /* comments */, or, as you said, remove the line of code ;)

ketanco
11-26-2009, 01:08 AM
okay thanks....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum