From 69fa69dc3b8a63b87b51b6cf64c44da127326485 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 30 May 2016 21:34:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=A8=E5=8D=95=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=B1=BB=E5=9E=8B=E4=BC=AA=E8=A3=85=E6=94=AF=E6=8C=81?= =?UTF-8?q?=20=E9=BB=98=E8=AE=A4=E5=8F=98=E9=87=8F=E4=B8=BA=20=5Fmethod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 2 ++ library/think/Request.php | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/convention.php b/convention.php index d958784b..25fab9ed 100644 --- a/convention.php +++ b/convention.php @@ -83,6 +83,8 @@ return [ 'url_controller_convert' => true, // 是否自动转换URL中的操作名 'url_action_convert' => true, + // 表单请求类型伪装变量 + 'method_var' => '_method', // +---------------------------------------------------------------------- // | 模板引擎设置 diff --git a/library/think/Request.php b/library/think/Request.php index 1bfaaf71..4c5f305d 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -417,7 +417,12 @@ class Request $this->method = $method; return; } elseif (!$this->method) { - $this->method = IS_CLI ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']); + $mask = $this->param(Config::get('method_var')); + if ($mask) { + $this->method = $mask; + } else { + $this->method = IS_CLI ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']); + } } return $this->method; }