因为跟前端对接接口时,常常需要写参数文档,于是懒癌晚期的我就写了一个接口,用于将php代码中的参数和注释匹配出来,直接复制给前端。

    public function getParam()
    {
$str = <<<A
        $projectNo             =     I('param.projectNo');                //项目编号
        $zlReturnIsDepot    =    I('param.zlReturnIsDepot');            //返还是否经由库房
        $zlReturnUser        =    I('param.zlReturnUser');            //返还库房接收人
        $zlReturnPhone        =    I('param.zlReturnPhone');            //返还库房联系方式
        $zlReturnAddress    =    I('param.zlReturnAddress');            //返还库房地址
A;
        preg_match_all('/(?<=[param|post|get]\.).*(?=\'|")/', $str, $match);
        preg_match_all('/(?<=\/\/).*/', $str, $match2);
        $data = array();
        $match = $match[0];
        $match2 = $match2[0];
        foreach ( $match as $k => $v ) {
            $data[ $v ] = $match2[ $k ];
        }
        $this->ajaxReturn([
            'code' => 200,
            'str'  => $str,
            'data' => $match,
            'date2' => $match2,
            'res' => $data
        ]);
    }

如若时光萧瑟去丶
111 声望9 粉丝

weakChickenPeng.