个性化阅读
专注于IT技术分析

Phalcon HTTP请求环境

点击下载

本文概述

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

取值

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

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

以下是相同行为的示例:

<?php

use Phalcon\Filter;

$filter = new Filter();

// Automatically applying the filter
$email = $request->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');

输出

Phalcon HTTP请求1

请求方法

Methods Description
公共setDI(Phalcon \ Interface $ dependencyInjector) 设置依赖项注入器。
公共getDI() 返回内部依赖注入器。
公用getServer(混合$ name) 从$ _SERVER超全局变量获取变量。
公众(混合$ name) 检查$ _REQUEST超全局变量是否具有特定索引。
公共hasPost(混合$ name) 检查$ _POST超全局变量是否具有特定索引。
公共hasPut(混合$ name) 检查PUT数据是否具有一定索引。
公共hasQuery(混合$ name) 检查$ _GET superglobal是否具有特定索引。
最终公开的hasServer(混合$ name) 检查$ _SERVER superglobal是否具有特定索引。
最终公共getHeader(混合$ header) 从请求数据获取HTTP标头。
公共getScheme() 获取HTTP模式(http / https)。
公共isAjax() 检查是否已使用ajax发出请求。
公共isSoap() 检查是否已使用SOAP发出请求。
public isSecure() 检查是否已使用任何安全层发出请求。
公共getRawBody() 获取HTTP原始请求正文。
公共getServerAddress() 获取活动的服务器地址IP。
赞(0)
未经允许不得转载:srcmini » Phalcon HTTP请求环境

评论 抢沙发

评论前必须登录!