Нет описания

Error.php 703B

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