📜  Phalcon响应

📅  最后修改于: 2021-01-07 09:33:39             🧑  作者: Mango

Phalcon回应

在Phalcon中,当产生任何请求时,用户提供手动响应或响应由控制器给出。响应文件在Phalcon \ Http \ Response下生成。 Http响应通常由标头和正文组成。

setStatusCode(404, 'Not Found');

// Set the content of the response
$response->setContent("Sorry, the e-mail doesn't exist.");

// Send response to the client
$response->send();

输出量

回应方法

Methods Description
public setDI (Phalcon\DiInterface $dependencyInjector) Sets the dependency injector
public getDI () Returns the internal dependency injector.
public setStatusCode (mixed $code, [mixed $message] Sets the HTTP response code.
public getStatusCode () Returns the status code.
public setHeaders (Phalcon\Http\Response\HeadersInterface $headers) Sets a headers bag for the response externally.
public getHeaders () Returns headers set by the user.
public setCookies (Phalcon\Http\Response\CookiesInterface $cookies) Sets a cookies bag for the response externally.
public Phalcon\Http\Response\CookiesInterface getCookies () Returns cookies set by the user.
public resetHeaders () Resets all the established headers.
public setExpires (DateTime $datetime) Sets an Expires header in the response that allows to use the HTTP cache.
public setNotModified () Sends a Not-Modified response.
public setContentType (mixed $contentType, [mixed $charset]) Sets the response content-type mime, optionally the charset.
public setEtag (mixed $etag) Set a custom ETag.
public setContent (mixed $content) Sets HTTP response body.
public getContent () Gets the HTTP response body.