📜  Phalcon请求

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

Phalcon请求环境

HTTP请求由浏览器发起,该浏览器包含有关请求的其他信息,例如标头数据,文件,变量等。基于Web的应用程序需要解析该信息,以便向请求者提供正确的响应。请求的所有信息都存储在目录Phalcon \ Http \ Request下。

取值

为了获取值,PHP根据请求的类型自动将数组类型确定为$ _GET和$ _POST。

Phalcon \ Http \ Request允许我们访问存储在$ _REQUEST,$ _ GET和$ _POST数组中的值,并使用过滤服务(即Phalcon \ Filter)对其进行过滤。

以下是相同行为的示例:

getPost('user_email', 'email');

// Setting a default value if the param is null
$email = $request->getPost('user_email', 'email', 'some@example.com');

// Setting a default value if the param is null without filtering
$email = $request->getPost('user_email', null, 'some@example.com');

输出量

请求方法

Methods Description
public setDI (Phalcon\DiInterface $dependencyInjector) Sets the dependency injector.
public getDI () Returns the internal dependency injector.
public getServer (mixed $name) Gets variable from $_SERVER superglobal.
public has (mixed $name) Checks whether $_REQUEST superglobal has certain index.
public hasPost (mixed $name) Checks whether $_POST superglobal has certain index.
public hasPut (mixed $name) Checks whether the PUT data has certain index.
public hasQuery (mixed $name) Checks whether $_GET superglobal has certain index.
final public hasServer (mixed $name) Checks whether $_SERVER superglobal has certain index.
final public getHeader (mixed $header) Gets HTTP header from request data.
public getScheme () Gets HTTP schema (http/https).
public isAjax () Checks whether request has been made using ajax.
public isSoap () Checks whether request has been made using SOAP.
public isSecure () Checks whether request has been made using any secure layer.
public getRawBody () Gets HTTP raw request body.
public getServerAddress () Gets active server address IP.