Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2008
    Posts
    139
    Plugin Contributions
    0

    Default Commenting PHP Files - Does Not Seem to Work

    Was trying to comment out some sections of code from my tpl_header file.

    I've tried both the <!-- ... --> and /* ... */ methods, but neither one actually works. Instead, my comment characters end up displaying on the website.

    I've done this in other mods, but don't understand why this does not work. the actual file comments made by the author use */ .. /*, which obviously works, so I'm not sure what's going on.

    Any suggestions?

    Thanks,
    -DBB1

  2. #2
    Join Date
    Apr 2006
    Location
    West Salem, IL
    Posts
    2,888
    Plugin Contributions
    0

    Default Re: Commenting PHP Files - Does Not Seem to Work

    In PHP, we use // to make a single-line comment or /* and */ to make a large comment block.
    Code:
    <?php
    
    //This is a comment
    
    /*
    This is
    a comment
    block
    */
    
    ?>
    Mike
    AEIIA - Zen Cart Certified & PCI Compliant Hosting
    The Zen Cart Forum...Better than a monitor covered with post-it notes!

  3. #3
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Commenting PHP Files - Does Not Seem to Work

    To add some more description:

    <?php

    //This is a comment

    /*
    This is
    a comment
    block
    */

    ?>

    <!-- at this point, this is out side of php, you can see the php is closed by ?> above, so here you need to comment like this -->
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  4. #4
    Join Date
    Jan 2008
    Posts
    139
    Plugin Contributions
    0

    Default Re: Commenting PHP Files - Does Not Seem to Work

    Quote Originally Posted by barco57 View Post
    In PHP, we use // to make a single-line comment or /* and */ to make a large comment block.

    <?php

    //This is a comment

    /*
    This is
    a comment
    block
    */

    ?>
    Quote Originally Posted by yellow1912 View Post
    To add some more description:

    <?php

    //This is a comment

    /*
    This is
    a comment
    block
    */

    ?>

    <!-- at this point, this is out side of php, you can see the php is closed by ?> above, so here you need to comment like this -->

    Thanks, folks!

    I understand what you're saying, and in fact have tried these methods, but the block of code I'm trying to comment out is a mixed bag of php and html, like most of the php files.

    So am I to understand that to comment out this single block of code, I need to use a combination of html comment tags for those lines, and php comment tags for those? If so, that seems very cumbersome, and would make it near impossible to tell later on that the one block of code was removed from service as part of a single edit.

    I must be missing something...

    DBB1

  5. #5
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Commenting PHP Files - Does Not Seem to Work

    unfortunately it is exactly that way. If you comment out template files, you can safely use the html comment like this:

    <!--

    some html here
    <?php

    //php code

    ?>
    some html here
    -->

    Note that, when you comment out hrml code, they are not displayed but the code is still there when you view source of the page.
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  6. #6
    Join Date
    Jan 2008
    Posts
    139
    Plugin Contributions
    0

    Default Re: Commenting PHP Files - Does Not Seem to Work

    Quote Originally Posted by DBB1 View Post
    Thanks, folks!

    I understand what you're saying, and in fact have tried these methods, but the block of code I'm trying to comment out is a mixed bag of php and html, like most of the php files.

    So am I to understand that to comment out this single block of code, I need to use a combination of html comment tags for those lines, and php comment tags for those? If so, that seems very cumbersome, and would make it near impossible to tell later on that the one block of code was removed from service as part of a single edit.

    I must be missing something...

    DBB1
    Well, I think I may have figured out what was going on... The block of code in question already had several single-line comments of the type <!-- .. -->.

    Using Textpad (which color-codes commented text as you type), I ended up discovering that the existing "<!-- -->" comment strings seemed to interrupt the overall block commenting that I was trying to do. I replaced those existing comments strings with those of the type "/* .. */" and finally got it to work!

    Thanks again!

 

 

Similar Threads

  1. Base price plus attribute does not seem to work for me
    By danilyn22 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 25 Mar 2011, 02:00 AM
  2. Google base feeder installed but does not seem to work!
    By antpez in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 19 Oct 2009, 10:54 PM
  3. Downloading files after sale does not work?
    By HansieNel in forum General Questions
    Replies: 11
    Last Post: 18 Mar 2009, 05:02 PM
  4. Ajax Yahoo menu does not seem to work
    By bradlawson in forum Basic Configuration
    Replies: 5
    Last Post: 25 Sep 2006, 06:06 AM

Posting Permissions

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