PHP

Comments

Remarks#

Keep the following tips in mind when deciding how to comment your code:

  • You should always write your code as if comments didn’t exist, using well chosen variable and function names.
  • Comments are meant to communicate to other human beings, not to repeat what is written in the code.
  • Various php commenting style guides exist (e.g. pear, zend, etc). Find out which one your company uses and use it consistently!

Single Line Comments

The single line comment begins with ”//” or ”#“. When encountered, all text to the right will be ignored by the PHP interpreter.

// This is a comment

# This is also a comment

echo "Hello World!"; // This is also a comment, beginning where we see "//"

Multi Line Comments

The multi-line comment can be used to comment out large blocks of code. It begins with /* and ends with */.

/* This is a multi-line comment.
   It spans multiple lines.
   This is still part of the comment. 
*/

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow