TOP-framework/framework/traits/Json.php

19 lines
357 B
PHP

<?php
namespace top\traits;
trait Json {
public function returnJson($msg, $code = 0, $data = [])
{
if (is_array($msg)) {
return json_encode($msg);
} else {
return json_encode([
'msg' => $msg,
'code' => $code,
'data' => $data
]);
}
}
}