PHP learn - Comments

In easy words , PHP comments are used to describe about the code so that another developer can understand the code easily .Also you can hide the unwanted code using comment .

If you comment the code then it will be non excitable .

See this Example :
 
<?php 
//this is my name 
$name =  "Akshay Dhiman";

// This code is not executable
// $commented_name =  "Akshay Dhiman";

echo $name ; 

?>
 

Output:

Akshay Dhiman
 
Inside PHP you can comment in two ways : 

  • Single Line Comment 
  • Multi-line Comment 


Single line Comment 

Now there is two ways to comment :
  1. ( // ) - This is one way to comment single line (c++ style)
  2. ( # ) - This another way to comment (Unix shell style)
See this Example:

  
// This is one way to comment single line (c++ style)  
# This another way to comment (Unix shell style)  
echo " Single line comment";  
?>  
 

Output:

Single Line Comment
 

Multi line Comment 

Inside PHP we can also comment multi lines . We can use ( /* i am comment text */ ) star and slash  like this . Let us how you one example .

Example :

<?php   
/* 
Everything inside is comment . Multi-lines supported that drop to next lines.
*/  
echo "Multi line comment";  
?>   

Output:

Multi line comment
  

Last Updated: 2018-07-06 12:32:44 By akshay

SHARE THIS

share_facebook share_twitter share_google_plus

Please Comment Here :