Nenhuma Descrição

Error.php 743B

1234567891011121314151617181920212223242526272829303132333435363738
  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. ];
  22. /**
  23. * 返回错误码
  24. * @var string
  25. */
  26. public static function getError($code = "400", $_ = false)
  27. {
  28. if (! isset(self::$errCodes[$code])) {
  29. $code = "400";
  30. }
  31. return ($_ ? "[{$code}]" : "")
  32. . self::$errCodes[$code];
  33. }
  34. }