Search code examples
phpclassparam

What does @param mean in a class?


What does the @param mean when creating a class? As far as I understand it is used to tell the script what kind of datatype the variables are and what kind of value a function returns, is that right? For example:

/**
 * @param string $some
 * @param array $some2
 * @return void
 */

Isn´t there another way to do that, I am thinking of things like: void function() { ... } or something like that. And for variables maybe (int)$test;


Solution

  • @param doesn't have special meaning in PHP, it's typically used within a comment to write up documentation. The example you've provided shows just that.

    If you use a documentation tool, it will scour the code for @param, @summary, and other similar values (depending on the sophistication of the tool) to automatically generate well formatted documentation for the code.