12345678910111213141516171819202122232425 |
- <?php
- // 应用公共文件
- function ajax_return($code = 0, $msg = '', $data = [])
- {
- $res = ['code' => $code, 'msg' => $msg, 'data' => $data];
- $response = \think\Response::create($res, 'json');
- throw new \think\exception\HttpResponseException($response);
- }
- function url(string $url = '', array $vars = [], $suffix = true, $domain = true)
- {
- return \think\facade\Route::buildUrl($url, $vars)->suffix($suffix)->domain($domain);
- }
- function rand_str($len = 6)
- {
- $str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- $res = '';
- for ($i = 0; $i < $len; $i++) {
- $key = rand(0, strlen($str));
- $res .= $str[$key];
- }
- return $res;
- }
|