Hi,
Comments in your code are handy, sometimes really helpful and for other people reading your code priceless, but comments can also help you debug your code.
How that works?
If you’re twelve levels deep buried in loops and suddenly things start going wrong you could start counting {curlies} but it’s easy to lose track of them, definitely when it’s complex and condensed code.
If you use comments to comment out code you know works you will be left with the code that doesn’t work.
Sometimes you see code posted in the fora that you really don’t feel like going through. There is a problem somewehre, the poster tells you, but there is several kilobytes of code cluttering up the real problem.
[php]
foreach ( $array as $key => $value )
{
there is lots of code here.
half a Peter Hamilton-book really.
Etcetera etcetera.
And eventually you fail to notice
/* the } is missing. */
[/php]
By the way, if you’re twelve levels deep you may want to consider breaking that code up in functions and other files. I’ll probably work, code is meant for computers. But people have to read it too sometimes.
PHP comes with several flavours of comments.
[php]// Comments out one line[/php]
[php]/* comments out everything between the stars */[/php]
Use it to your advantage.
O.