error.php 571 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * 错误提示
  4. * User: ssh 2019.8.9
  5. * Date: 2019/8/9
  6. * Time: 16:47
  7. */
  8. namespace common\components;
  9. use Yii;
  10. class error
  11. {
  12. public $error = '';
  13. public $hasError = false;
  14. private static $instance = null;
  15. private function __construct()
  16. {
  17. }
  18. public static function instance()
  19. {
  20. if (empty(self::$instance)) {
  21. self::$instance = new self();
  22. }
  23. return self::$instance;
  24. }
  25. public function setError($msg)
  26. {
  27. $this->error = $msg;
  28. Yii::info($msg);
  29. $this->hasError = true;
  30. }
  31. public function getError()
  32. {
  33. return $this->error;
  34. }
  35. }