How we can use PHP comments in the code


What are PHP comments and how we can write

PHP comments in code are lines that not run as part of the program. Its primary aim is to read the code by someone who is looking at it. the purpose of the comments is that let someone understands your code. many programmers work on multiple projects some project has the highest priority. that highest priority project comes later in this situation programmers who work on the current project with is partially done has been postponed for some days. in that scenario, the programmer puts the comments in the code so that they can easily remember how much work completed and how much remain using PHP comments.

Types of comments

There are two types of comments :

  • Single line comments
  • Multi-line comments

Single line comments :
The purpose of single-line comments is it can prevent execution for a single line only. it can be done in two ways.

  • // (C++ style single line comment)
  • #(Unix Shell-style single line comment)
single line comments

In the above example we can replace the first comment as per our purpose for example we can write there Title of code so others can understand what is the code about. In the second comment, we can write about a short description of the code. And in the third comment, we can see that that line will not be executed.

Multi-line comments :
In some situations, a single line can not describe the working programmer wants to write some more lines for documents. in this case, multi-line comments are useful.

  • Multi line comments start with /* and ends with */.
multi-line comment

In the above example we can see that there is more then one line, in such cases we can use multi-line comments. we can write detail about the code or project in which we are working. we can also prevent multiple lines from execution. it helps a programmer for testing a particular code or to write some lines which not want to be executed.