As far as I know, there are 3 types of comments recognized by PHP:
/* A block comment */
// A single-line comment
# Also a single-line comment
However, many coding standards, for example, those of PEAR or Kohana, discourage the last type of comments with no explanation. The question is, why is it so? Is this syntax planned for deprecation anytime soon?
Of is a preposition that indicates relationships between other words, such as belonging, things made of other things, things that contain other things, or a point of reckoning.
Of is a preposition. Of commonly introduces prepositional phrases which are complements of nouns, creating the pattern: noun + of + noun. This pattern is very common, especially to indicate different parts, pieces, amounts and groups: Lima is the capital of Peru.
The preposition “of” can be used in many different contexts. It can be used to help quantify a time or measurement (e.g., “the fifth of September” or “three pounds of potatoes”) and even identify a location (e.g., “south of California”), but it can also create more general relationships between objects and their nouns.
This preposition shows that something or someone belongs to something or someone. Such as of, with and to.
C-language comment style has become an industry standard. There's nothing wrong with using #
comments at all unless the particular coding standard for your project or workplace prohibits it. Standards are the key to yielding readable code.
In many cases, //
and/or /* */
are considered standard comment syntax for programming languages. The only exception that commonly is encountered is VB, which uses '
. In contrast, #
is often considered the standard comment syntax for shell scripting.
PHP was designed to perform both tasks originally. PHP can and does function reasonably well as a shell scripting language and can be invoked from the command line. It has functions to handle reading from stdin and writing to stdout. This is probably the origin of the #
syntax for comments. #
is probably discouraged because PHP is thought of as a programming language nowadays, rather than a tool for shell scripting. Specifically, the style guides that the question references are for web apps, rather than some shell tool.
From the links you posted, this seems like a purely stylistic choice. PEAR and Kohana would like to have some unity when it comes to style and they have (possibly arbitrarily), chosen to prefer C-Style comments to UNIX/Perl-style ones.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With