Http输入输出
常量 | |
---|---|
HttpIO::PARAM_TYPE_URL |
string(3) "url" |
HttpIO::PARAM_TYPE_OLDDATA |
string(3) "old" |
HttpIO::METHOD |
null |
HttpIO::PROTOCOL |
null |
HttpIO::REFERRER |
null |
HttpIO::USER_AGENT |
empty |
HttpIO::IP |
null |
HttpIO::IS_AJAX |
bool false |
API - Core_HttpIO
- HttpIO::$headers - 将输出的header列表
- HttpIO::$status - 页码状态
- HttpIO::$uri - 当前页面URI
- HttpIO::$params - 当前页码参数
- HttpIO::__construct
- HttpIO::setup - 执行初始化,只执行一次
- HttpIO::GET - 获取$_GET数据
- HttpIO::POST - 获取$_POST数据
- HttpIO::COOKIE - 获取$_COOKIE数据
- HttpIO::REQUEST - 获取$_REQUEST数据
- HttpIO::sanitize - 对字符串进行安全处理
- HttpIO::sanitize_decode - 对字符串进行反向安全处理
- HttpIO::redirect - 页面跳转
- HttpIO::set_cache_header - 页面输出header缓存
- HttpIO::send_headers - 发送header数据
- HttpIO::add_header - 添加header头信息
- HttpIO::status - 设置HTTP的状态
- HttpIO::current_controller - 获取当前控制器
- HttpIO::param - 获取当前页指定参数
- HttpIO::query - 返回query构造参数
- HttpIO::uri - 获取新的URI
- HttpIO::url - Create a URL from the current request. This is a shortcut for:
- HttpIO::csrf_check - CSRF 检测
- HttpIO::set_params_controller - 根据控制器设置参数
- HttpIO::get_primary_domain - 获取一个域名的主域名
执行初始化,只执行一次
自动添加HTML5的AJAX跨越支持
获取$_GET数据
// 获取原始数据
$get_array = HttpIO::GET(null,HttpIO::PARAM_TYPE_OLDDATA);
// 获取原始数据为URL格式
$url = HttpIO::GET('url',HttpIO::PARAM_TYPE_URL);
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key |
string |
$key | null |
$type |
string |
返回类型,false或不传,则返回原始数据 例:HttpIO::PARAM_TYPE_URL | null |
获取$_POST数据
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key |
string |
$key | null |
$type |
string |
返回类型,false或不传,则返回原始数据 例:HttpIO::PARAM_TYPE_URL | null |
获取$_COOKIE数据
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key |
string |
$key | null |
$type |
string |
返回类型,false或不传,则返回原始数据 例:HttpIO::PARAM_TYPE_URL | null |
获取$_REQUEST数据
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key |
string |
$key | null |
$type |
string |
返回类型,false或不传,则返回原始数据 例:HttpIO::PARAM_TYPE_URL | null |
对字符串进行安全处理
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$str |
$str |
对字符串进行反向安全处理
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$str |
$str |
页面跳转
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$url |
string |
Redirect location | |
$code |
integer |
Status code: 301, 302, etc | integer 302 |
void
页面输出header缓存
0表示不缓存
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$time |
int |
缓存时间,单位秒 | integer 86400 |
发送header数据
添加header头信息
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key |
string |
$key | |
$value |
string |
$value |
设置HTTP的状态
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$status |
int |
$status | null |
获取当前控制器
Controller
获取当前页指定参数
$id = $request->param('id');
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key |
string |
Key of the value | null |
$default |
mixed |
Default value if the key is not set | null |
mixed
返回query构造参数
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$params |
array |
Array of GET parameters | null |
string
获取新的URI
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$params |
array |
Additional route parameters | null |
string
Create a URL from the current request. This is a shortcut for:
echo URL::site($this->request->uri($params), $protocol);
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$params |
string |
Route name | null |
$protocol |
array |
URI parameters | null |
string
CSRF 检测
同一个主域名下的请求将返回 true
否则返回 false
boolean
根据控制器设置参数
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$controller |
Controller |
$controller |
获取一个域名的主域名
支持传入URL
HttpIO::get_primary_domain('test.myqee.com'); //myqee.com
HttpIO::get_primary_domain('http://v3.myqee.com/docs/'); //myqee.com
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$host |
string |
$host |
string