Zen Cart Logo
Forums / General Questions / Commenting PHP Files - Does Not Seem to Work

Commenting PHP Files - Does Not Seem to Work

Locked

Views: 14,982

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
15 Jan 2009, 10:37 PM
#1
dbb1 avatar

dbb1

Zen Follower

Join Date:
Jan 2008
Posts:
139
Plugin Contributions:
0

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

15 Jan 2009, 10:41 PM
#2
barco57 avatar

barco57

Totally Zenned

Join Date:
Apr 2006
Location:
West Salem, IL
Posts:
2,844
Plugin Contributions:
0

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.```

<?php //This is a comment /* This is a comment block */ ?>
16 Jan 2009, 4:11 AM
#3
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

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 -->
17 Jan 2009, 7:06 AM
#4
dbb1 avatar

dbb1

Zen Follower

Join Date:
Jan 2008
Posts:
139
Plugin Contributions:
0

Re: Commenting PHP Files - Does Not Seem to Work

barco57:

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 */ ?>

yellow1912:

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

17 Jan 2009, 7:16 AM
#5
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

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.

17 Jan 2009, 8:20 AM
#6
dbb1 avatar

dbb1

Zen Follower

Join Date:
Jan 2008
Posts:
139
Plugin Contributions:
0

Re: Commenting PHP Files - Does Not Seem to Work

DBB1:

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!