• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » PHP » How many Types of Comments are there in PHP
Next →
← Prev

How many Types of Comments are there in PHP

By Dinesh Thakur

Comments are only intended for the programmer. They will not be displayed or executed. They identify as part of the program without interfering in the program. Comments are among the trivial elements in the success of a program; and this is why it is important to use them with intelligence.

We’ll be covering the following topics in this tutorial:

  • A comment, what is it?
  • The Linear Comment

A comment, what is it?

A comment in a programming language, is a line written in natural language (mother tongue of the developer for example) will not be executed by the interpreter (or compiler according to the language used). Its function is to describe or explain some of the code that will reveal is difficult to decipher for maintenance or collaborative work (multiple developers working on the same program).

The comments are therefore particularly useful for a developer, but they are more so when it is a complete team working on the same project. They allow to impose among other nomenclatures and organization in writing the code of a collaborative project. In addition, the comments provide easier maintenance program by its author or a third party.

Another highlight of comments is the generation of technical documentation. Indeed, there are applications such as PHP Documentor that relies on a particular syntax comments to generate documentation for an application. This ensures a significant time saving for a development team.

Comment code is also part of good programming practices to adopt. But it still not be entered to the other extreme where each instruction code become commented. The clarity and readability of the program would then be affected.

The Linear Comment

There are two kinds of comments. The comment on a single line and multi-line comment. Let us look at both methods to review a text on one line.

Comments on a single line

<?php
          // This is a first line comment
               echo 'Hello World!';
  echo'<br />';
         # This is a second line comment
               echo 'Hello World' ;
?>

PHP offers two ways to comment on a text placed on a line. The most widely used method is the first example with the double slash (//) unlike the second using a pound sign (#).

The multiline comment

It allows to comment a written text on multiple lines. It is very frequently used by developers. These comments are defined using symbols /* and */. The example below illustrates their jobs.

Multiline comments

<?php
      /*
         This program was written by Emacs
          It displays the string 'Hello Word!' on the screen
      */
          echo 'Hello World!';
?>

You’ll also like:

  1. PHP Constants Types
  2. PHP Variable Types
  3. PHP Operator Types
  4. JavaScript Comments
  5. Comments in C++
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

PHP Tutorials

PHP Tutorials

  • PHP - Home
  • PHP - Features
  • PHP - Magic Methods
  • PHP - Imagefilter
  • PHP - Arrays Numeric
  • PHP - Sessions
  • PHP - Forms Processing
  • PHP - clone()
  • PHP - Cookies
  • PHP - Variable Types
  • PHP - First program
  • PHP - call()
  • PHP - Iterator interface
  • PHP - Imports files
  • PHP - Exception Handling
  • PHP - set() and get()
  • PHP - Install MAMP
  • PHP - Functions
  • PHP - Constants Types
  • PHP - Comments Types
  • PHP - OOP's
  • PHP - OOps Use
  • PHP - PHP Code & Redirect 301
  • PHP - Control structures
  • PHP - Abstract Classes
  • PHP - Control structures
  • PHP - Classes
  • PHP - MySQL NULL values
  • PHP - Methods Visibility
  • PHP - Operator Types
  • PHP - Short tags Not use
  • PHP - Object and class
  • PHP - Secure Passwords

Other Links

  • PHP - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW