PHP comment

From Wiki @ Karl Jones dot com
Revision as of 20:27, 20 September 2016 by Karl Jones (Talk | contribs) (Created page with "A '''PHP comment''' is a region of text within a PHP code island which is ignored by the PHP processor. Comments are added with to make the PHP code easier to unders...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A PHP comment is a region of text within a PHP code island which is ignored by the PHP processor.

Comments are added with to make the PHP code easier to understand.

Single-line comment

<?php

// This is a single-line comment

?>

Single-line comment

<?php

/*
 This is a multi-line comment
 Lorem ipsum, comment comment comment ...
*/

?>

Uses

How best to make use of comments is subject to dispute; different commentators have offered varied and sometimes opposing viewpoints. There are many different ways of writing comments and many commentators who offer sometimes conflicting advice.

Comments can be used as a form of pseudocode to outline intention prior to writing the actual code. In this case it should explain the logic behind the code rather than the code itself.

Comments can be used to summarize code or to explain the programmer's intent. According to this school of thought, restating the code in plain English is considered superfluous; the need to re-explain code may be a sign that it is too complex and should be rewritten, or that the naming is bad.

Sometimes source code contains a novel or noteworthy solution to a specific problem. In such cases, comments may contain an explanation of the methodology.

See also

External links