Google News
logo
How to write comments in PHP?
In PHP, there are two ways to write comments :

1. Single-line comments :

Single-line comments start with two forward slashes (//) and continue until the end of the line.

Example :
// This is a single-line comment in PHP​

2. Multi-line comments :

Multi-line comments start with a forward slash followed by an asterisk (/*) and end with an asterisk followed by a forward slash (*/).
Example :
/*
This is a multi-line comment in PHP
It can span multiple lines and is useful for documenting code
*/​

* Comments in PHP are used to add notes and explanations to code that help other developers understand what the code does.

* They can also be used to temporarily disable code during testing or debugging.

* Comments are ignored by the PHP interpreter and have no effect on the execution of the program.