Adding comments to PHP code is a very useful practice. Comments allows you to add some descriptive text that you can use to document or remind you on what the various parts of the PHP script is doing.

Comments are not sent to the browser, so it won’t be visible in the actual page you load in your browser, but it will be visible in your text editor you use for writing your PHP script.

You can place comments anywhere within the PHP codes. PHP provides 2 forms of commenting format – single and multi line comments.

Single-line comments are denoted by 2 forward slashes, like this: //. This will indicate to the PHP parser that this line is to be ignored and not processed for display.

Multi-line comments requires an open (/*) and a close (*/) delimiter. The comment continues from the open delimiter, regardless of line breaks until it sees the closing delimiter.

Any characters are allowed in the single-line comments. However, for multi-line commens, you cannot have /* or */ characters nested within existing multi-line comment blocks.

Documenting and commenting within the codes is a very tedious affair, but it is an essential habit that any good developer should cultivate. Sometimes you might have to revisit your codes written many years ago, and to be able to follow the comments written within is a godsend and a real time saver.

Good Luck!