Keine Beschreibung

Error.php 829B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App;
  3. /**
  4. * API服务端 - 错误码
  5. * @author Flc <2016-7-31 11:27:09>
  6. */
  7. class Error
  8. {
  9. /**
  10. * 错误码
  11. * @var [type]
  12. */
  13. public static $errCodes = [
  14. 0 => "成功",
  15. 200 =>'请求成功',
  16. 1001 => '未分配销售',
  17. 2000 =>'请求参数不合法',
  18. 2001 =>'未查询到有效数据',
  19. 2002 =>'密码错误',
  20. 2003 =>'充值卡余额不足',
  21. 2014 =>'该用户还不是会员',
  22. 2015 =>'不能领取当月礼包',
  23. ];
  24. /**
  25. * 返回错误码
  26. * @var string
  27. */
  28. public static function getError($code = "400", $_ = false)
  29. {
  30. if (! isset(self::$errCodes[$code])) {
  31. $code = "400";
  32. }
  33. return ($_ ? "[{$code}]" : "")
  34. . self::$errCodes[$code];
  35. }
  36. }