The Comments are added in programming code with the purpose of making the code easier to understand. It makes the code more readable and hence easier to update the code later. Comments are ignored by compiler while running the code. In PHP, there are two ways of putting a comment.
It starts with // or # and ends with the end of that line. Anything after // or # to the end of line is a single line comment and will be ignored by compiler.
//single line comment. statements; # single line comment.
The below example illustrates how to use single line comments in a PHP script. The compiler ignores the comments while compiling the code.
<?php #first single line comment. echo "Hello World!.\n"; //second single line comment. ?>
It starts with /* and ends with */. Anything between /* and */ is a block comment and will be ignored by compiler.
/*block comment.*/ statements; /*block comment.*/ statements;
The below example describes how to use multiple line comments in a PHP code which is ignored by the compiler while compiling the code.
<?php /*first block comment. */ echo /*second block comment.*/"Hello World!.\n"; ?>