Class: WindHttpRequest
Source Location: /http/request/WindHttpRequest.php
Class WindHttpRequest
Method Summary
string |
getPathInfo() |
返回包含由客户端提供的、跟在真实脚本名称之后并且在查询语句(query string)之前的路径信息 |
boolean |
isGet() |
返回请求是否为GET请求类型 |
boolean |
isPost() |
返回请求是否为POST请求类型 |
boolean |
isPut() |
返回请求是否为PUT请求类型 |
Methods
WindHttpRequest __construct(
)
|
|
初始化Request对象
API Tags:
string|'' getAcceptCharset(
)
|
|
返回客户端程序可以能够进行解码的数据编码方式
这里的编码方式通常指某种压缩方式
API Tags:
string getAcceptLanguage(
)
|
|
返回客户端程序期望服务器返回哪个国家的语言文档
Accept-Language: en-us,zh-cn
API Tags:
返回当前请求头中 Accept: 项的内容,
Accept头字段用于指出客户端程序能够处理的MIME类型,例如 text/html,image/*
API Tags:
string|object|array getAttribute(
$key, [string
$defaultValue = ''], string
$name
)
|
|
根据名称获得服务器和执行环境信息
主要获取的依次顺序为:_attribute、$_GET、$_POST、$_COOKIE、$_REQUEST、$_ENV、$_SERVER
Parameters:
string |
$name: |
获取数据的key值 |
string |
$defaultValue: |
设置缺省值,当获取值失败的时候返回缺省值,默认该值为空字串 |
|
$key: |
|
API Tags:
Return: | 返回获得值 |
Access: | public |
string getBaseUrl(
[boolean
$absolute = false]
)
|
|
获取基础URL
这里是去除了脚本文件以及访问参数信息的URL地址信息: Example:
请求: http://www.phpwind.net/example/index.php?a=test
1]如果: $absolute = false:
返回: example
2]如果: $absolute = true:
返回: http://www.phpwind.net/example
Parameters:
boolean |
$absolute: |
是否返回主机信息 |
API Tags:
Information Tags:
Throws: | WindException 当返回信息失败的时候抛出异常 |
返回访问IP
如果获取请求IP失败,则返回0.0.0.0
API Tags:
mixed getCookie(
[string
$name = null], [string
$defaultValue = null]
)
|
|
返回cookie的值
如果$name=null则返回所有Cookie值
Parameters:
string |
$name: |
获取的变量名,如果该值为null则返回$_COOKIE数组,默认为null |
string |
$defaultValue: |
当获取变量失败的时候返回该值,默认该值为null |
API Tags:
mixed getEnv(
[string
$name = null], [string
$defaultValue = null]
)
|
|
返回ENV的值
如果$name为null则返回所有$_ENV的值
Parameters:
string |
$name: |
获取的变量名,如果该值为null则返回$_ENV数组,默认为null |
string |
$defaultValue: |
当获取变量失败的时候返回该值,默认该值为null |
API Tags:
mixed getGet(
[string
$name = ''], [string
$defaultValue = null]
)
|
|
获得$_GET值
Parameters:
string |
$name: |
待获取的变量名,默认为空字串,当该值为null的时候将返回$_GET数组 |
string |
$defaultValue: |
当获取的变量不存在的时候返回该缺省值,默认值为null |
API Tags:
string getHeader(
string
$header, [string
$default = null]
)
|
|
获取Http头信息
Parameters:
string |
$header: |
头部名称 |
string |
$default: |
获取失败将返回该值,默认为null |
API Tags:
获得主机信息,包含协议信息,主机名,访问端口信息
Example:
请求: http://www.phpwind.net/example/index.php?a=test
返回: http://www.phpwind.net/
API Tags:
Information Tags:
Throws: | WindException 获取主机信息失败的时候抛出异常 |
boolean getIsAjaxRequest(
)
|
|
返回该请求是否为ajax请求
如果是ajax请求将返回true,否则返回false
API Tags:
返回包含由客户端提供的、跟在真实脚本名称之后并且在查询语句(query string)之前的路径信息
Example:
请求: http://www.phpwind.net/example/index.php?a=test
返回: a=test
API Tags:
Information Tags:
mixed getPost(
[string
$name = null], [string
$defaultValue = null]
)
|
|
获取请求的表单数据
从$_POST获得值
Parameters:
string |
$name: |
获取的变量名,默认为null,当为null的时候返回$_POST数组 |
string |
$defaultValue: |
当获取变量失败的时候返回该值,默认为null |
API Tags:
返回请求页面时通信协议的名称和版本
API Tags:
mixed getQuery(
[string
$name = null], [
$defaultValue = null], string
$default
)
|
|
获取请求数据
将从$_GET中获取数据
Parameters:
string |
$name: |
待获取的变量名,默认为null |
string |
$default: |
如果获取变量失败则返回该值,默认为null |
|
$defaultValue: |
|
API Tags:
返回浏览当前页面的用户的主机名
DNS 反向解析不依赖于用户的 REMOTE_ADDR
API Tags:
获得用户机器上连接到 Web 服务器所使用的端口号
API Tags:
mixed getRequest(
[string
$key = null], [mixed
$defaultValue = null]
)
|
|
获得用户请求的数据
返回$_GET,$_POST的值,未设置则返回$defaultValue
Parameters:
string |
$key: |
获取的参数name,默认为null将获得$_GET和$_POST两个数组的所有值 |
mixed |
$defaultValue: |
当获取值失败的时候返回缺省值,默认值为null |
API Tags:
string getRequestMethod(
)
|
|
获得请求的方法
将返回POST\GET\DELETE等HTTP请求方式
API Tags:
获得请求类型
如果是web请求将返回web
API Tags:
初始化请求的资源标识符
这里的uri是去除协议名、主机名的 Example:
请求: http://www.phpwind.net/example/index.php?a=test
则返回: /example/index.php?a=test
API Tags:
Information Tags:
Throws: | WindException 当获取失败的时候抛出异常 |
获取请求链接协议
如果是安全链接请求则返回https否则返回http
API Tags:
返回执行脚本名称
Example:
请求: http://www.phpwind.net/example/index.php?a=test
返回: index.php
API Tags:
Information Tags:
Throws: | WindException 当获取失败的时候抛出异常 |
返回当前执行脚本的绝对路径
Example:
请求: http://www.phpwind.net/example/index.php?a=test
返回: /example/index.php
API Tags:
Information Tags:
Throws: | WindException 当获取失败的时候抛出异常 |
mixed getServer(
[string
$name = null], [string
$defaultValue = null]
)
|
|
返回Server的值
如果$name为空则返回所有Server的值
Parameters:
string |
$name: |
获取的变量名,如果该值为null则返回$_SERVER数组,默认为null |
string |
$defaultValue: |
当获取变量失败的时候返回该值,默认该值为null |
API Tags:
返回当前运行脚本所在的服务器的主机名。
如果脚本运行于虚拟主机中 该名称是由那个虚拟主机所设置的值决定
API Tags:
返回服务端口号
https链接的默认端口号为443 http链接的默认端口号为80
API Tags:
mixed getSession(
[string
$name = null], [string
$defaultValue = null]
)
|
|
返回session的值
如果$name=null则返回所有SESSION值
Parameters:
string |
$name: |
获取的变量名,如果该值为null则返回$_SESSION数组,默认为null |
string |
$defaultValue: |
当获取变量失败的时候返回该值,默认该值为null |
API Tags:
返回浏览器发送Referer请求头
可以让服务器了解和追踪发出本次请求的起源URL地址
API Tags:
返回User-Agent头字段用于指定浏览器或者其他客户端程序的类型和名字
如果客户机是一种无线手持终端,就返回一个WML文件;如果发现客户端是一种普通浏览器, 则返回通常的HTML文件
API Tags:
返回请求是否为DELETE请求类型
如果请求是DELETE方式请求则返回true,否则返回false
API Tags:
返回请求是否为GET请求类型
如果请求是GET方式请求则返回true,否则返回false
API Tags:
返回请求是否为POST请求类型
如果请求是POST方式请求则返回true,否则返回false
API Tags:
返回请求是否为PUT请求类型
如果请求是PUT方式请求则返回true,否则返回false
API Tags:
请求是否使用的是HTTPS安全链接
如果是安全请求则返回true否则返回false
API Tags:
初始化request对象
对输入参数做转义处理
API Tags:
void setAttribute(
string|array|object
$data, [string
$key = '']
)
|
|
设置属性数据
Parameters:
string|array|object |
$data: |
需要设置的数据 |
string |
$key: |
设置的数据保存用的key,默认为空,当数组和object类型的时候将会执行array_merge操作 |
API Tags:
void setServerPort(
int
$port
)
|
|
设置服务端口号
https链接的默认端口号为443 http链接的默认端口号为80
Parameters:
API Tags:
|
|