Page 1 of 1

Should comments have tags at the beginning and end ?

Posted: Mon Mar 21, 2011 1:58 am
by newphper
Hi All, I am very new to programming and php so please do not lose patience with me if I asked some very simple questions.

I have been looking at this piece of code and it is very obvious that php tags have been placed at the beginning and end of a comment ?

From what I have learned (self taught), this is wrong ? All answers and help appreciated, many thanks in anticipation.


<?php
$print_invited_members .= "<br>";
$print_im .= $print_invited_members;}?>
<tr>
<td colspan="5">
<input name="no_response" type="submit" value="No response">
<input name="responded_yes" type="submit" value="Responded Yes">
<input name="responded_no" type="submit" value="Responded No">
<input name="move_to_attending" type="submit" value="Move to attending">

</td>
</tr>
</form>
</table>

<?php /////////********** CORRELATE MEMBERS *************////////////// ?>
<table style="vertical-align:top" align="center" width="800" border="1" bgcolor="E0FFFF" cellspacing="5">
<tr>
<td bgcolor="#00ff00" colspan="6">
<div align="center"> <a name="CM">BOOKINGS</a></div>
</td>
</tr>

Re: Should comments have tags at the beginning and end ?

Posted: Mon Mar 21, 2011 9:03 am
by divedj
Comments have to be marked as comments. However beeing in html mode it doesn't make very much sense raping a comment in php tags when just a simple <!-- Comment Here --!> would do the same without giving the server an extra php task just to ignore a comment.

Re: Should comments have tags at the beginning and end ?

Posted: Mon Mar 21, 2011 10:11 am
by social_experiment

Code: Select all

<?php /////////********** CORRELATE MEMBERS *************////////////// ?>
This might also return an error because everything after // is commented, including your closing php tag.

Re: Should comments have tags at the beginning and end ?

Posted: Mon Mar 21, 2011 4:46 pm
by gully_mi_seh
you should write all your comment on the same line with this method. Your closing php tags should not be at the same line than your comment. With the double slash you do not have to specify the closing comment tag. It just transform into comment the entire line starting after the starting comment tag. If you want to use a starting and a closing tag, you should use /* as starting and */ as ending.The open-close method is really effective for multi-line comment...

Re: Should comments have tags at the beginning and end ?

Posted: Mon Mar 21, 2011 6:25 pm
by newphper
Thank you all for the quick replies, It seemed wrong but being very new to php, I had to ask the question in case their was a valid reason for doing what was done. Cheers.