简体   繁体   中英

Comments for documentation PHP post data and returning JSON

I have two questions actually:

  1. For some functions I am posting forms to them, can I mention them as @params in comments or what:

     /* some descriptions * * @param string userName */ public function add(){ $userName = $_POST['user'] ...... } 
  2. From some function I am returning data as JSON, how to mention JSON as return type and format:

      /* 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. See eg the draft PHP-FIG recommendation for what's (mostly) conventional.

If you're returning a JSON string it would be better to document it as

@return string Text here describing what is being returned

since as far as PHP is concerned it's just another string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM