您的位置 首页 php

关于 TP6 自定义状态码

下面由thinkphp框架教程栏目给大家介绍关于 TP6 自定义状态码,希望对需要的朋友有所帮助!

config 目录下新建code.php

<?phpreturn [    'success'=>1,    'error'=>0,    'need_login'=>-1,    'user_is_registed'=>-2,];

文件中使用

config('code.success')

统一api返回数据

common.php新建函数

<?php// 应用公共文件function show($code,$msg = "OK",$data = [],$httpCode = 200){    $result = [        'code'=>$code,        'msg'=>$msg,        'data'=>$data,    ];    return json($result,$httpCode);}

文章来源:智云一二三科技

文章标题:关于 TP6 自定义状态码

文章地址:https://www.zhihuclub.com/25871.shtml

关于作者: 智云科技

热门文章

网站地图