__toString() . '}'; } $reflection_object = new ReflectionObject($object); $properties = $reflection_object->getProperties(); $values = array(); foreach ($properties as $property) { if ($property->isStatic() || !$property->isPublic()) { continue; } $name = $property->getName(); $value = $property->getValue($object); if (isPrimary($value)) { $values[$name] = $value; } elseif (is_array($value)) { $values[$name] = json_encode($value, JSON_UNESCAPED_UNICODE); } else { $values[$name] = '@' . get_class($value); } } return get_class($object) . '@{' . json_encode($values, JSON_UNESCAPED_UNICODE) . '}'; } public static function errorInfo() { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $file = str_replace(SERVER_URL, '', $trace[0]['file']); $line = $trace[0]['line']; if (isset($trace[1]['function'])) { $function = $trace[1]['function']; } else { $function = 'unknow'; } $message = '[' . $file . ":" . $line . ' ' . $function . ']'; foreach (func_get_args() as $item) { $message .= toString($item) . ' '; } return $message; } /** * 方便调试输出 */ public function echoLine() { $message = ''; foreach (func_get_args() as $item) { $message .= self::toString($item) . ' '; } $text = '[PID ' . getmypid() . ']' . $message; if (self::isCli()) { echo $text . PHP_EOL; } else { echo $text . '
'; } } public static function isCli() { return php_sapi_name() == 'cli'; } }