PHP常用注释TAG

/**
* @link http://jianboo.com
*
* @param bool $id
*
* @return mixed
* @return bool | string | JSON
*
* @example 
* 
* $.post('index.php?action=add',{key: 1001, value: 'JSON Object'})
* 
*
* @todo finish function 
*
* function foo
* @since Version 2.0.1
*
* @version beta1.0.1
*
* @deprecated deprecated since 2.0
*
* @author Jianbo Li 
*
* @copyright Copyright (c) 2017, Jianbo Li
*
* @internal
**/

示例1

/**
  * JSON Request
  * 服务端接收的POST数据为JSON格式
  * 
  * @param raw
  * @return Array
  **/
  public function request () {
    return json_decode(file_get_contents("php://input"), true);
  }

示例2

/**
  * Custom Ajax Response
  * 以JSON格式输出结果,用于返回Ajax请求
  * 
  * @param Array $data
  * @return JSON
  *
  * @example
  * $this->response(array("code"=> 200, "data"=> [1,2,3,4,5,6]))
  * 
  **/
  public function response($data) {
    header("Content-type:application/json");
    print_r(json_encode($data));
  }

你可能感兴趣的:(PHP常用注释TAG)