The first type of comments that we can use in PHP, and the most common: In this type of comments, we can only use a single line. It consists of two diagonals together at the beginning of the line.
// Here we can comment.
The second type of comments, and the second most used: Everything between the opening and closing characters, will be comments. It consists of an opening with a slash and an asterisk, and a closing with an asterisk and a slash, these can span several lines and disable the code that is in the middle of the labels.
Multiple line comments with closing.
We can write whatever or disable whatever with this.
echo "This does not work because it is disabled with the comment";
The third type of comments, which is not the worst form for that: These comments are the same as the first type, only, instead of using two characters, it is only one. It consists of starting with a number symbol.
# This is a line comment.
# And it cannot be displayed in a line break.
Advantages of each type
First type: In the first type of comments, we can write short comments, without having to close the comment.
Second type: This is useful when we need to comment a lot of text, for example, with several lines, or some blocks of code so that they do not work.
Third type: Good for short or single line comments, and for many it might be an advantage to just have to put the # character, instead of the two // characters that are used in the first type. All comment options are valid, and their use may vary depending on the type of project we are working on, or the customs of each programmer. A prominent feature of all three types of comments is that they can start anywhere in the document, and not necessarily at the beginning of a line. To verify its behavior, it is worth using a code editor with syntax coloring.