[英]Comments for documentation PHP post data and returning JSON
I have two questions actually: 我实际上有两个问题:
For some functions I am posting forms to them, can I mention them as @params
in comments or what: 对于某些功能,我要向他们发布表单,我可以在评论中以@params
形式提及它们@params
?
/* some descriptions * * @param string userName */ public function add(){ $userName = $_POST['user'] ...... }
From some function I am returning data as JSON, how to mention JSON as return type and format: 从某些函数中,我将数据作为JSON返回,如何将JSON称为返回类型和格式:
/* some descriptions * * @return JSON [{id, name,...}] */
You can write anything you like in comments. 您可以在评论中写任何您喜欢的东西。 That said, it's not a conventional use - @param
and @return
should describe the actual parameters and return values of the function in question. 就是说,这不是常规用法- @return
@param
和@return
应该描述所讨论函数的实际参数和返回值。 See eg the draft PHP-FIG recommendation for what's (mostly) conventional. 参见例如PHP-FIG建议草案 ,了解(大部分)常规建议。
If you're returning a JSON string it would be better to document it as 如果您要返回JSON字符串,最好将其记录为
@return string Text here describing what is being returned
since as far as PHP is concerned it's just another string. 因为就PHP而言,它只是另一个字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.