8
I’ve always been curious about this, but since it never changed my life at all, I never sought to know.
If there is a difference, what would be between these types of comments in PHP?
/* Comentário 1 */
/** Comentário 2 */
8
I’ve always been curious about this, but since it never changed my life at all, I never sought to know.
If there is a difference, what would be between these types of comments in PHP?
/* Comentário 1 */
/** Comentário 2 */
8
/* Comentário 1 */
, is a comment anyway with //
or #
. It is curious to comment that no kind of comment cancels the closing tagline ?>
/** Comentário 2 */
, is called doclet whatever is inside it, usually noted with arroba @
is one or more information that some frameworks read to make the configuration of certain features easier, so there is no need to configure some xml or external file.
If any setting is mandatory and you forget the second asterisk, you will get a little headache if you do not know this subtle difference.
See an example taken from symfony how to set up a route, can be done through an xml, yaml or php file.
class HelloController
{
/**
* @Route("/hello/{name}", name="hello")
*/
public function indexAction($name)
{
return new Response('<html><body>Hello '.$name.'!</body></html>');
}
}
This information can still be used by Ides to offer a better autocomplete for example with setting the type of the input or output parameter in addition can be used to generate documentation.
rray, it was +/- what I imagined, because I always saw doclets of these well extended with possible functions, I imagined that it could have some functionality and indeed has. Thank you very much for the clarification.
5
Comments with the second * can be used, for example, to generate documentation.
All frameworks I know in PHP use the second * to later generate code documentation.
A tool to generate PHP code documentation is Phpdocumentor.
This saves a lot of time when writing documentation.
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Correct @rray response. Also, try using two asterisks at the beginning in the sublime text and at the line below do not start with another asterisk. It will mark as error. If you leave only an asterisk, will recognize as comment of multiple lines, common
– Wallace Maxters