In PHP, I've noticed people put the "@" symbol in source code comments. One great example is anything WordPress. When you look at the source, you see things like
/** Results of the last query made
*
* @since 1.0.0
* @access private
* @var array|null
*/
var $last_result
(wp-db.php, Line 124)
It changes the syntax highlighting in my editor so I'm assuming it does something, but I'm not sure what it does. Would someone explain what the "@" symbol does in comments?
Comment symbols. Two ampersands (&&) can also be used for an end-of-line comment, but they are usually seen in older code. If an asterisk (*) is the first character in a statement, the entire line is considered a comment.
If # is the first character of line, then entire line is a comment. It can be used in the middle of a line.
/* */ (multiline comment) Multiline comments are used for large text descriptions of code or to comment out chunks of code while debugging applications. Comments are ignored by the compiler.
In Python, we use the hash symbol # to write a single-line comment.
These are PHPDoc
comments. They're intended to be machine-parseable to support automated documentation and IDE code completion.
The previous answers are correct in stating that the @ symbols in source comments are PHPDoc comments. They can additionally be used for something called "annotation" which adds metadata to some element of code and can affect the behavior of an application. It's not officially supported in PHP but it's been under discussion for several years and is in use in the Symfony, Doctrine, and other projects.
An excellent explanation via slideshow (no affiliation with me) of all things PHP and annotation:
http://www.slideshare.net/rdohms/annotations-in-php-they-exist
A generic discussion of the subject of annotation:
http://en.wikipedia.org/wiki/Annotation
An RFC from 2010 regarding the implementation of annotations in PHP:
http://wiki.php.net/rfc/annotations
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