How to write comments in PHP?

A comment in PHP code is a line that is not read by compiler.. Its only purpose is to be read by

someone who is looking at the code or we can say it is used for documentation purpose.

Comments can be used to:

  • Let others understand what you are doing
  • 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

There are two types of comments in php-:

  1. Single line comment: #(hash) and // (double slash) is used for comment purpose.

          Example:

          //we are using php

          # we are using php

  1. Multi line comment

          /* This is a multiple-lines comment block that can span over multiple lines */


FOLLOW US ON LinkedIn



Explore Tutu'rself