mirror of
https://github.com/tznb1/TwoNav.git
synced 2025-08-10 08:51:49 +00:00
v2.0.07-20230405
This commit is contained in:
28
system/Msg.php
Normal file
28
system/Msg.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
//返回JSON信息(状态码)
|
||||
function code($code){
|
||||
header('Content-Type:application/json; charset=utf-8');
|
||||
exit(json_encode(['code'=>$code]));
|
||||
}
|
||||
//返回JSON信息(常用型)
|
||||
function msg($code,$msg){
|
||||
$data = ['code'=>$code,'msg'=>$msg];
|
||||
header('Content-Type:application/json; charset=utf-8');
|
||||
exit(json_encode($data));
|
||||
}
|
||||
//返回JSON信息(自定义信息)
|
||||
function msgA($data){
|
||||
header('Content-Type:application/json; charset=utf-8');
|
||||
exit(json_encode($data));
|
||||
}
|
||||
|
||||
//如果是POST则返回Json信息,否则返回HTML文本
|
||||
function Amsg($code,$msg){
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST'){
|
||||
msg($code,$msg);
|
||||
}else{
|
||||
header("content-Type: text/html; charset=utf-8");
|
||||
exit('<title>错误</title><font color="red">错误代码:'.$code.'<br />错误信息:'.$msg.'</font>');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user