In PHP the comment
is a line or section of code or text that is not executed as part of the program, and is simply ignored.
Comments
are your friend. Use them as often and as much as you like.
The main purpose and benefits for having and using comments are:
PHP supports several ways of commenting:
// This is a single-line comment
# This is also a single-line comment
/* This is a
multi-line comment */
Single line comments start with //
.
Any text or code between //
and the end of the line will be ignored (will not be executed).
Although not commonly used as often, the hashtag symbol #
can also be used for single line comments, and it behaves the same as //
.
// Outputs a hello message:
echo "Hello World!" ;
echo "This is Fun!" ; // Yes it is fun
// The following code is commented out:
//echo "Let's go already!";
Any text or code between /*
and */
, no matter if it is on a single line, multiple lines, or within code, will be ignored (will not be executed):
/* The famous "Hello World!".
This example uses PHP's echo command to display it.
Feel free to copy this example and use it however you like.
Modified By : Tim Tolbert
Last Modified: July 15, 2025
*/
echo "Hello World!" ;
Thank you for reading, I hope you found this blog post (tutorial) educational and helpful.
About | Contact Us | Privacy | Terms & Conditions | © 2025 - T&J Divisions, LLC, All Rights Reserved |