PHP 05: PHP comments

Comments are the part of the PHP code , that is not executed. It’s a note note to the person who is reading the code.

Usage of comments

  • Let other programmers / developers understand what is written and what the code does .
  • Comments can help you ! It will remind you what you’ve written if you you come back after several days or years.

Types of comments

  1. Single line commnts
  2. Block comments

Example of comments

We can use // or # for single line comments and /* */ for block comments. Look at the example below.

<?php
# example of single line comment
echo "Hello world"; // this is also single line comment
/*
This is an
example of
multi-line comment
*/
?>

See the output below. Comments have no effect in the output.

Output:

Hello world

But do not try to nest comments.

<?php
/* this is
commented */ but this don't */
?>

Related posts

Md. Monirul Alom

Md. Monirul Alom

I am a Full Stack Web developer. I love to code, travel, do some volunteer work. Whenever I get time I write for this blog