Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2009
    Posts
    195
    Thanks
    26
    Thanked 0 Times in 0 Posts

    comment tag not working

    Hello,

    Code:
    <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:


    Code:
    <!--
    <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?

  • #2
    New to the CF scene
    Join Date
    Sep 2008
    Location
    Pernambuco, Brazil
    Posts
    8
    Thanks
    0
    Thanked 1 Time in 1 Post
    If there is PHP code inside a <!-- comment -->, it will still be processed, so if you have something like:
    Code:
    <!-- <li><? echo $name; ?></li> -->
    The expected behaviour is something like:
    Code:
    <!-- <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.
    Last edited by Cisneiros; 11-26-2009 at 12:11 AM.

  • #3
    Regular Coder
    Join Date
    Jul 2009
    Posts
    195
    Thanks
    26
    Thanked 0 Times in 0 Posts
    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?

  • #4
    New to the CF scene
    Join Date
    Sep 2008
    Location
    Pernambuco, Brazil
    Posts
    8
    Thanks
    0
    Thanked 1 Time in 1 Post
    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

  • Users who have thanked Cisneiros for this post:

    ketanco (11-26-2009)

  • #5
    Regular Coder
    Join Date
    Jul 2009
    Posts
    195
    Thanks
    26
    Thanked 0 Times in 0 Posts
    okay thanks....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •