Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the "@" Symbol for in Comments?

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?

like image 777
Goldentoa11 Avatar asked Mar 29 '12 18:03

Goldentoa11


People also ask

What are symbols 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.

Which symbol was used for adding comments?

If # is the first character of line, then entire line is a comment. It can be used in the middle of a line.

What is the symbol for a multi line code comment?

/* */ (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.

What symbols signifies the beginning of a comment in Python?

In Python, we use the hash symbol # to write a single-line comment.


2 Answers

These are PHPDoc comments. They're intended to be machine-parseable to support automated documentation and IDE code completion.

like image 183
Alex Howansky Avatar answered Oct 16 '22 20:10

Alex Howansky


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

like image 21
Night Owl Avatar answered Oct 16 '22 21:10

Night Owl