What is the comments in PHP?
In this episode you will learn :
- What is the Comments on PHP
- How many Comments on PHP?
- What is Single Line Comments in PHP? How is Single Line Commented write in PHP?
- What is the Multi Line Comments on PHP? How to make a Multi Line comment in PHP?
What is PHP Comments?
PHP Comments: Comments in PHP or any Programming Language are the explanations or footnotes of a code or programmer’s source code. We can call it Coding Documentation. Generally, any Programming Language Compiler and Interpreter avoid comments (Ignore) without executing the code as a code. With Comments System, we will not be used right now in addition to Coding Documentation, but we can also hide the codes that we can use in the future.
How Many Comments on PHP?
Comments in PHP are basically two types:
1. Single Line Comments (Each line has to use a comment mark separately)
2. Multi Line Comments (For multiple lines comment, use the mark only once.)
What is the Single Line Comments in PHP? How is Single Line Commented use in PHP?
A programmer in PHP uses the comment mark on each line separately, it is called Single Line Comments. It is also call short comments. Single Line comment on PHP use # (hash) and // (two slashes). Let’s better understand the following example:
<?php echo 5+4; // Here's a single-line PHP comments for 5 and 4 summation echo "Hello World"; # Here's another single-line PHP comments for "Hello World" String ?>
Explanation: Notice that the two lines here that we have enclosed on single line comment, these two lines will not come in our browser.
What is the Multi Line Comments on PHP? How to make a Multi Line comment in PHP?
A programmer in PHP uses only one comment mark for multiple lines. In the terminology of PHP, it is called Multi Line Comments. Multi Line Comments with / * * / in PHP Let’s better understand the following example:
<?php /* Here's a long PHP comments spread over many lines. You can format a multi-line comment any way you like. */ echo "Hello World"; ?>
Explanation: Notice that all the lines we have here are basically tied to the line comment, they will not come in our browser.