note 15206 deleted from pear.standards.comments by nlopess
| From: | nlopess@php.net | Date: | Fri, 25 Jun 2004 16:39:15 +0000 |
| Subject: | note 15206 deleted from pear.standards.comments by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71669@lists.php.net to get a copy of this message | ||
Note Submitter: aulbach@unter.franken.de
----
I add some note for debugging with comments to the note of william.NO@scriptingbiz.SPAM.com:
You may come perhaps to a point, where you have made a syntax error (forgotten a " or ) for
example) which you cannot find (I'm sure you know what I mean: those evil misswriting you have
been looking 6 or more times over and even don't see it!). Even the source-code-mode of PHP
won't help to find the misswriting (ok, sometimes it's really a big help, but this is
another good tip). Sometimes it's so bad, that PHP shows an error in a file, where it really
can't be.
I solved those problems in the past often with the method to comment as long as the script
won't bother me any longer with an syntax error. Logically the syntax error must be inside the
area, which I have been commented. So I uncomment it, as long, as the error appears again. Then I
repeat this as long as I found the error (I call this "Debugging with trial and error".
Hey, this really works, and it takes less time than it sounds!).
The most effective method to do this, is to use /* */-comments. Bad for you, if you have used these
allready *everywhere* in your code, cause it's a great fun to replace */ with *//* or x/ and
back again; you can make very wrong things and may produce bad side-effects if you are not so
familiar with this method.
So my tip is to use a compromise: only use /* */-comments before a function or at the top or end of
a file. Use //-comments inside functions and the rest of the program - so that you can uncomment a
hole function with
/*
function bla ()
{
....
}
*/
and see what happens whithout looking if there is a /**/-comment inside it. You may also use
#-comments instead
#function bla()
#{
...
#}
to do debug with trial and error (most editors help you to add and remove many of these # into a
file).