3 Things You Should Know to Add Comments in PHP
In this step, we will learn about the comments. We are already using comments in the above steps. There are 2 types of comments in PHP.
Other Articles in PHP Basics Section
- Creating a PHP File with PHP info
- Displaying Text with PHP
- Comments with PHP
- PHP Configuration File
- PHP Error Reporting
Quickly Navigate to Other Sections in PHP Tutorials
They are Single Line Comments & Multi-Line Comments. And single line comments we can write them in 2 ways with 2 forward slashes and with a pound symbol #.
// Single Line Comments
# Single Line Comments
You can start the multi-lined comments, multiple times. But you can end multi-lined comments only once, you should remember this while using multi-line comments.
don't end multi
/* commented lines
You should use the comments while writing the code, these comments will become useful when your code becomes complex or when you invite other people to work on the same project or if you are giving away the code to others for free or paid, they will easily understand the code with the help of the comments and they can easily modify the code based on their requirement.
Don’t write long paragraphs for comments, use simple hints with few sentences or words to remember the logic why you are doing that step.