Due to their shared inheritance from the C programming language, PHP and JavaScript share many similarities, one of which is commenting. First there’s the single-line comment, which looks like this:
// This is a comment
This style uses a pair of forward slash characters (//
) to inform JavaScript that everything that
follows on that line is to be ignored. And then we have multiline
comments, which look like this:
/* This is a section of multiline comments that will not be interpreted */
You start a multiline comment with the sequence /*
and end it with */
. Just remember that you cannot nest multiline
comments, so make sure that you don’t comment out large sections of code
that already contain multiline comments.