Hello Coders,
When you learn coding and after that you develop many big software/application.
After some years when you look back to your code for which purpose you have written that code.
Then you may not remember any thing why you have written bunch of code and for which purpose.
So, for solution to this we use comments in our code.
Comments is nothing but bunch of lines written in code which will never be executed.
The use of comments in PHP is commented code to be read by someone who is looking at the code.
Before you start with PHP comments you need to install PHP in your local system.
For that, this article may help you :
What is PHP? How to install it on windows? Full Guide
In PHP there are 2 types of comments
- Single Line Comment
- Multiple Lines Comment
1.) Single Line Comment
We can use this type of comment to comment Single line of code.
<!DOCTYPE html>
<html>
<body>
<?php
// This is a single-line comment
# This is also a single-line comment
?>
</body>
</html>
Using // or # you can comment single line in PHP.
2.) Multiple Lines Comment
We can use this type of comment to comment multiple lines of code.
<!DOCTYPE html>
<html>
<body>
<?php
/*
This is a multiple-lines comment block
write down your notes here.
*/
?>
</body>
</html>
In PHP multiple Line comments starts with /* and end with */ .
All lines between them are now commented and that will never be executed.
And that’s it…
If you have any query on comments in PHP then let me know by commenting below.
Happy to help you.
Thank You.
Leave a Reply