| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace common\traits;
- trait ErrorTrait
- {
- public $error = '';
- public $error_code = 0;
- public static $static_error = '';
- public static $static_error_code = 0;
- /**非静态调用储物处理 */
- public function setError($msg, $error_code = 0)
- {
- $this->error_code = $error_code;
- $this->error = $msg;
- }
- public function getError()
- {
- return $this->error;
- }
- public function getCodeError()
- {
- return array(
- 'code' => $this->error_code,
- 'error' => $this->error,
- );
- }
- /**静态调用错误处理 */
- public static function setStaticError($msg, $error_code = 0)
- {
- self::$static_error = $msg;
- self::$static_error_code = $error_code;
- }
- public static function getStaticError()
- {
- return self::$static_error;
- }
- public static function getStaticCodeError()
- {
- return array(
- 'code' => self::$static_error_code,
- 'error' => self::$static_error
- );
- }
- }
|