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?
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
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.
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.