Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

What are PHP Comments

 

PHP Comments

PHP comments can be used to describe any line of code so that other developers can understand the code easily. It can also be used to hide any code.

PHP supports single line and multi-line comments. These comments are similar to C/C++ and Perl style (Unix shell-style) comments.

PHP Single Line Comments

There are two ways to use single-line comments in PHP.

  • // (C++ style single line comment)
  • # (Unix Shell style single line comment)
  1. <?php  
  2. // this is C++ style single line comment  
  3. # this is Unix Shell style single line comment  
  4. echo "Welcome to PHP single line comments";  
  5. ?>  

Output:

Welcome to PHP single line comments

PHP Multi-Line Comments

In PHP, we can comments on multiple lines also. To do so, we need to enclose all lines within /* */. Let's see a simple example of a PHP multiple line comment.

  1. <?php  
  2. /* 
  3. Anything placed 
  4. within comment 
  5. will not be displayed 
  6. on the browser; 
  7. */  
  8. echo "Welcome to PHP multi line comment";  
  9. ?>  

Output:


Welcome to PHP multi-line comment

Must watch other services : 

Android App Design ServicesHire Android Developer Online 


WordPress TrainingCake PHP Training Course  Laravel Course


Post a Comment

0 Comments