34,333
edits
Changes
→PHP Multi-line Comments
== PHP Multi-line Comments ==
Multi-line comments are wrapped in /* and */ delimiters. The /* marks the start of the ''comment block'' and the */ marks the end. The following example demonstrates the use of multi-line commenting in PHP:
<pre>
<?pre
/*
This a multi-line block
of comments
*/
?>
Multi-line comments are useful when you have notes you want to make in the code that will take up more than one line. The ability to mark blocks of lines as comments avoids the necessity of placing the single line comment marker at the start of each comment line.
Another useful application of multi-line comments is to comment out blocks of PHP code temporarily. It is quite commomn to have written some PHP script and then wonder if you can re-write it so that it is perhaps more efficient or reliable. In this situation you can comment out the old script fragment so that it is no longer executed and write some new code. If it turns out your new code is worse than the original (which happens from time to time) you can simply remove the new code and uncomment the old to bring it back into the execution flow.
== Summary ==
The objectives of this chapter were to hopefully raise your awareness of the importance of commenting your PHP code and also to provide an overview of how to use the commenting mechanism provided by PHP. Both single and multi-line comments can easily be added to PHP code using the approrpiate markers. Try to get into the habit of commenting your code as you write. Both you and those who have to maintain your code in the future will be glad you did.