📜  在 laravel api 中编码 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:41.603000             🧑  作者: Mango

代码示例1
//In base controller
protected function jsonResponse($data, $code = 200)
{
    return response()->json($data, $code,
        ['Content-Type' => 'application/json;charset=UTF-8', 'Charset' => 'utf-8'], JSON_UNESCAPED_UNICODE);
}
//In your controller
$this->jsonResponse($data);