*/ class Error { /** * 错误码 * @var [type] */ public static $errCodes = [ // 系统码 '0' => '成功', '200' => '成功', '400' => '未知错误', '401' => '无此权限', '500' => '服务器异常', '9999' => '数据库错误', // 功能 '1001' => '标签id无效', '1002' => '类别id无效', '1003' => '菜名id无效', '1004' => 'time参数无效', '1005' => 'type参数无效', '1006' => 'value参数无效', '1007' => 'menu_id无效', '1008' => '非法请求', '1009' => '反馈信息不能为空', '1010' => '请求成功,但返回内容为空', ]; /** * 返回错误码 * @var string */ public static function getError($code = '400', $_ = false) { if (!isset(self::$errCodes[$code])) { $code = '400'; } return ($_ ? "[{$code}]" : '') . self::$errCodes[$code]; } }