Single Line Comment in PHP
In this article, we will see how to make single line comment in PHP .
What are comments
Comments are something like notes inside the PHP code. Comments are ignored by the PHP engine.
Uses of comments
Comments are used to explain code the logic so that we can understand the code later; as well as other developers can read and understand the code easily. Comments are used to increase the readability and understandability of the source code.
If we don’t want to execute some parts of the code, we can comment on them so that they can be ignored by the PHP engine. Comments have no effect on the execution of a program.
Types of comments in PHP
There are 2 types of comments in PHP:
- Single line comments
- Multiline comments
In this article, we will discuss only single line comment
What are single-line comments
- Anything written after the “//” double backslash on the line is treated as a comment
- Anything written after the “#” hash on the line is treated as single line comment.
Syntax:
// comments goes here
# comment goes here
Example
<?php
# echo "HEllo world";
// echo "HEllo world";
?>