时间:2021-07-01 10:21:17 帮助过:160人阅读
config 目录下新建code.php
<?php
return [
'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 自定义状态码的详细内容,更多请关注gxlcms其它相关文章!