Reputation: 1760
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?
Upvotes: 13
Views: 5022
Reputation: 4223
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
Upvotes: 3
Reputation: 131
This is typically done to auto generate documentation from source code files. In this case, the @_ are used to identify meta data about the variable. Instead of being evaluated in order, @var can tell the documentation parser that the following text describes the variable and so on.
Upvotes: 0
Reputation: 53573
These are PHPDoc
comments. They're intended to be machine-parseable to support automated documentation and IDE code completion.
Upvotes: 7
Reputation: 48636
Such notations serve as a way to create a documentation parser out of comments. So, the first @ could be identified as the version, the second as the arguments and so on.
Upvotes: 0