Item within comment in PHP

0

Ifthe"@return string" within a PHP file's encoding is deleted, will the coding undergo significant changes? Can I delete all comments including "@return string"?

And finally, why did it look a different color?

    
asked by anonymous 17.06.2018 / 23:40

2 answers

1

All content within /* */ is a comment and all comments will be ignored when running the application, ie they will never interfere with the final result of any application

So yes you can delete, however it is not recommended, on the contrary, it is best to insert this in all other places, this explains the operation, in this case, what the function should return

Comments that begin with /** means that they are documentation comments, many IDEs use this data that is in those comments to give more information about the function:

In the example some information about the path parameter of the readFile function of JavaScript (Node.js) is shown, also note that although javascript is poorly typed, that is, it does not define the types of variables in function description has the information that path must be a string, number, buffer or url. This is very common in weakly typed languages, for example, so the person knows what should be passed in that parameter of that function

In addition to defining what should be passed by the parameter and the return can be set the author, version, if it is obsolete, make comments on the constructor and destructor (in the case of class)

The different color is because your IDE recognized that this was a documentation of the function

    
18.06.2018 / 00:27
2

No, @return string is just method documentation, in DocBlock format. Your IDE and other tools, for example, PHPDoc , use these special comments to give you information of what the code does.

In this case, @return is indicating what kind of value the function returns, which is string.

You can delete the entire comment, but I recommend using this feature to comment on your personal code.

The different color is the IDE that understands PHPDoc and "paints" differently to indicate that it is something "special".

When you are writing a call to this function, the IDE will show a tooltip that will use these comments so you know how to use it.

    
17.06.2018 / 23:57