PHP Tutorial

Define PHP

PHP Installation

PHP INI File

PHP Comment

PHP Case Sensitivity

PHP Variable, DataType

PHP Echo & Print

PHP Operators

PHP Receiving Input

Decision Making - if...else

PHP Switch Case

PHP Loops

PHP Jumping Statement

PHP Image Gallery

PHP File Upload

PHP Arrays

PHP Date Functions

PHP String Functions

PHP Math Functions

PHP Functions

PHP Variable Scope

PHP Constant Variable

PHP Superglobals

PHP Form Validation

PHP Include Statement

PHP Filter

PHP File Handling

PHP Cookies

PHP Session

PHP Send Emails

PHP Captcha

PHP MySQL Select

PHP MySQL Insert

PHP MySQL Delete

PHP MySQL Update

PHP MySQL Injection

PHP Assignment

Page Stats

Visitor: 671

PHP Comment

A PHP comment is a line that is written in between the PHP file but not read/execute by the server. The main purpose of comment is to understand what you are doing, or Remind yourself of what you did - Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments can remind you of what you were thinking when you wrote the code. PHP supports 2 type of comments:

  1. Single-line Comment:If you want to write a comment in one line than single-line comment is used. It is applied using two forward slashes or with a # symbol.
    // - This is a single-line comment
    # - This is also a single-line comment
  2. Multi-line Comment: If you want to write a comment for 2 or more lines that multi-line is used. It is start with forward slash and a asterisk and end by asterisk and a backward slash. /* This is a Multi-line comment */

Example 1: Single-line and Multi-line comment

<?php
    echo "Comments in PHP";
    //echo "This is a Single Line Comment and will not be displayed";
    #echo "This is also a Single Line Comment and not displayed.";
    
    /*
      echo "This is multiline comment.";
      echo "This line will not display";
      echo "This line is also a comment will not be displayed";
    */
?>