Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There are three types of comments that may be used in PHP. They are block comments (/* */), inline comments (//), and shell comments (#).

Block Comments

Block comments are used for doc commenting, commenting out large sections of code. Blesta uses PHPDoc syntax for all doc comments. Block comments may not be used as a substitute for inline comments.

Warning
titleIncorrect
Code Block
languagephp
/*
This is a comment.
*/
if ($foo > $bar) {
    return $bar
}
Tip
titleCorrect
Code Block
languagephp
/**
 * This is a DocBlock comment 
 */ 
function foo() {

}

 

Inline Comments

Inline comments should be used to clarify code. You are discouraged from using inline comments at the end of a line as this creates run-on lines and your comment is unlikely to be read.

Warning
titleIncorrect
Code Block
languagephp
/*
Calculate the circumference
*/
$c = 2*pi()*$r;
Note
titleCorrect, but discouraged
Code Block
languagephp
$c = 2*pi()*$r; // Calculate the circumference
Tip
titleCorrect
Code Block
languagephp
// Calculate the circumference
$c = 2*pi()*$r;

...

Shell Comments

These comments should only be used to identify TODO comments.

...