header = array_merge($this->header, $header); } else { $this->header[] = $header; } foreach ($this->header as $value) { header($value); } return $this; } /** * 返回内容 * @param $data * @return false|int|null|string */ public function send($data) { if ($data instanceof Response) { return $data; } else { // 处理响应数据,并返回 $this->content = $this->getContent($data); return $this; } } public function notFound() { $this->header([ 'HTTP/1.1 404 Not Found', 'Status: 404 Not Found' ]); return <<is('ajax')) { $this->header('Content-Type: application/json'); return $this->returnJson($data); } else { $this->header('Content-Type: text/html; charset=utf-8'); $filename = $request->controller() . '/' . $request->method(); return View::instance()->fetch($filename, $data); } } elseif (is_bool($data)) { return ($data) ? 'true' : 'false'; } else if (is_object($data)) { return '[OBJECT]'; } return $data; } /** * 直接echo处理 * @return string */ public function __toString() { return $this->content; } }