I spent more than a few minutes searching the other day to determine how to remark a line in an Apache .htaccess file so I decided a post of how to remark things in various scripting solutions might be a nice thing to have posted in this section of the forums.
For those who might not understand the remarks function, it a method for posting comments that are not executed. They are ignored by the processing system or the web browser. They serve the purpose of leaving a trail while writing a script or web page so that you can modify it as you need to. They are also useful for marking the starting and ending point of a particular portion of a script.
In html code a line like this one is not displayed in the browser:
PHP Code:
<!-- Comments go here -->
It is displayed in the source file and my understanding is that bots can read it. It is handy to use if you want to take a line or two out of the code and see the effect before you delete or modify it.
In PHP a line preceded by 2 forward slashes is ignored and not processed:
PHP Code:
// echo "some string here";
will result in that echo not being processed or displayed.
PHP also has another remark function where an entire segment of a script can be deactivated. It starts with /* and ends with */
PHP Code:
/*
this line of code and
this line of code
and this one also will be ignored
*/
This is really useful if you want to turn off a script routine while you test a few other things.
As mentioned above, I usually mark the start and stop point of a script fragment/routine using remarks.
PHP Code:
// mysql start
lines of code
// END mysql
Apache .htaccess files use the # symbol as the remark designator.
PHP Code:
# This line of code will not be read or executed by Apache
Basic. Does anyone still write in basic?
Basic uses rem as the ignore designator.
PHP Code:
rem write anything you want and it will be ignored
In most cases the vast majority of remarks will be removed from the production version of script or web page though there are times and reasons to leave some of them in place.