config 目錄下新建code.php
return?[
'success'=>1,
'error'=>0,
'need_login'=>-1,
'user_is_registed'=>-2,
];
文件中使用?
config('code.success')
統(tǒng)一api返回?cái)?shù)據(jù)
common.php新建函數(shù)
//?應(yīng)用公共文件
function?show($code,$msg?=?"OK",$data?=?[],$httpCode?=?200){
$result?=?[
'code'=>$code,
'msg'=>$msg,
'data'=>$data,
];
return?json($result,$httpCode);
}
本文來自PHP中文網(wǎng)尸诽,原文地址:https://www.php.cn/phpkj/thinkphp/466555.html?推薦教程:《thinkphp》