• thinkphp5--请求对象request


    判断请求类型

    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;
    }
    
  • 相关阅读:
    P4839 P哥的桶 题解(线段树维护线性基)
    线性基入门
    Lowest Common Ancestor 题解(lca+思维)
    B
    java string对象的简单方法
    AtCoder Grand Contest 016 D
    FFT
    回文自动机(BZOJ2565)
    二维RMQ
    AC自动机(BZOJ1030)
  • 原文地址:https://www.cnblogs.com/liwuming/p/10317869.html
Copyright © 2020-2023  润新知