Edit Article

C style commentUNIX style commentSingle line PHP style comment

Edited by Nikunj Gandhi, Zach, Ned Whitney, Maniac and 1 other

Ad

Edit Steps

  1. 1
    A Comment in PHP is part of a script which is ignored by the web server while executing PHP scripts.
    Ad
  2. 2
    A comment is the portion of a program that exists only for the human reader. Comments are used for helping the next person who reads your code figure out what you were thinking when you wrote it.
  3. 3
    There are three types comment in PHP.

EditMethod 1 of 3: C style comment

Example: /*This is a comment in PHP */

EditMethod 2 of 3: UNIX style comment

Example: #This is single comment for PHP

EditMethod 3 of 3: Single line PHP style comment

Example: //This is example comment in PHP



Edit Tips

  • HTML comments and PHP comments are both different, so when you are using scripting(HTML and PHP mix), take care of PHP execution.
  • For example, in the below code, there is an HTML comment, but it still executes.
Ad

<!--<div id="example"><?php echo 'hello'; ?></div>-->

Article Info

Categories: Web Programming

Recent edits by: Maniac, Ned Whitney, Zach

Ad

Thanks to all authors for creating a page that has been read 977 times.

Was this article accurate?

YesNo
x

Thank Our Volunteer Authors.

Follow us on Google+