Brak opisu

Error.php 527B

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