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 :
//this is my name 
$name =  "Akshay Dhiman";

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

echo $name ; 



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";  


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 :

Everything inside is comment . Multi-lines supported that drop to next lines.
echo "Multi line comment";  


Multi line comment

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


share_facebook share_twitter share_google_plus

Please Comment Here :