判断请求类型
isGet:判断当前请求类型是否是get请求
isPost:判断当前请求类型是否是get请求
isAjax:判断当前请求类型是否是Ajax请求
这三个方法都是根据method方法的返回值进行匹配的:
public function method($method = false){
if (true === $method) {
// 获取原始请求类型
return $this->server('REQUEST_METHOD') ?: 'GET';
} elseif (!$this->method) {
//http://www.digpage.com/web_request.html
if (isset($_POST[Config::get('var_method')])) {
$this->method = strtoupper($_POST[Config::get('var_method')]);
$this->{$this->method}($_POST);
} elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
$this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
} else {
$this->method = $this->server('REQUEST_METHOD') ?: 'GET';
}
}
return $this->method;
}