PHP 7 Comments

Laravel

147

w3alert.com

14-12-2019


PHP Comments

A comment is a type of text that is ignored by PHP. The comment is written so that your code can be understood by other programmers or developers.

In PHP, The main intention of a comment is to serve as a note for you, web developers or Programmers who can work the source code of the website.

Note: PHP comments can be used to code checking and debugging.

Types of PHP Comment

  • One or Single-line Comment
  • Multi-line Comment

Single-line comment

The single-line comment tells the interpreter to ignore everything that happens on the line that is to the right of the comment. One-line comment type to "//" or "#" and all text to the right will be ignored by the PHP interpreter.

There are two types of single-line comments in PHP.

It begins with // (Double Slash).

e.g.:- // This is addition function.

It begins with # (Hash).

e.g.:- # This is function need to re-check.

Example For Understand Single line comment:

<!DOCTYPE html>
<html>
<body>

<?php
echo "Hello"; // Single line comment

echo "w3alert"; # Single line comment
?>
 
</body>
</html>

Multi-line comment

Multi-line PHP comments can be used to write large blocks of code or multiple line comments. Many line PHP comments begin with "/ *" and end with "* /"

Begins with /* (Slash Star) and Ends */ (Star Slash).

e.g.:- /* This is 
          Multi-line
          comment
       */

Example For Understand Multi line comment:

<!DOCTYPE html>
<html>
<body>

<?php
 /* This is 
    Multi-line
    comment
 */
 echo "Welcome to w3alert.com";

?>
 
</body>
</html>