PHP Comments | PHP Tutorials

Comments in PHP?

During programming, if we want the compiler to ignore any text, that is, some text that the programmer wants to write some information related to the code, then it is called a comments line.

PHP Comments

If the programmer wants to put a line in PHP as a comment, then the following two techniques can be used:

  1. Single Line Comments
  2. Multiple Line Comments

1) Single-line comments: 

If the user wants to keep only one line as a comments line then //' double slash or '#' hash mark has to be used for it. Whatever text he types after applying this symbol, the compiler will ignore it. Like the following 

Example:

<?php
echo "Welcome to rkonline" ."<br>"." "; // Welcome Message
echo "for learning PHP language"; #Which language learn
?>

Result:

Welcome to rkonline
for learning PHP language

Welcome to rkonline
for learning the PHP language

2) Multiple line comments: 

In PHP, if one or more lines like the whole paragraph have to be commented on, then the '/*...*/ symbol is used for this. Like the following example: 

Example:

<?php
echo "Welcome to rkonline "."<br>" ." "; /* Here Start Multiple Commnets to ignore compiler
echo "HTML Language"; compiler ignore these two line
echo "Javascript Language"; compiler ignore these two line
 */
echo "PHP Language"; 
?>

Result:

Welcome to rkonline
PHP Language

In the above examples, all written in #, //, and /* ......*/ will be in the form of comments. The compiler will ignore them.

Post a Comment

0 Comments

Comments