Comment Tag in PHP | PHP Examples
×


PHP Comments

198859

PHP comments are used to understand the functionality of the PHP code. One can easily distinguish the lines of code through comments.

Complier ignore the lines which are commented by the programmer. Comments make code more friendly and with the help of comments one programmer can easily understands the code written by others.

PHP language supports both single and multi-line comments. We can also hide the code through comments.

We have two way to define code as a comment in PHP:

  1. Single line commenting
  2. Multiple line commenting

For single line comments we use either // or #.

Example:

<?php

// echo "What are you looking for?";
echo "Try this.";

?>

Example:

<?php

# echo "Or this";
echo "Hey! I'm here.";

?>

Above example is to comment only a single line. You can also use '//' and '#' to comment a single line.

To comment more lines, use this  /*  ....... */:

<?php

/*
echo "My name";
$name="Vihaan";
This is used to comment the paragraph or lines more than one.
*/

echo "Got it ?";

?



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments