From 5e22d69e13b9214f50ea0cac0798c1976e5c9bf8 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 17 May 2016 10:13:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BRequest=E7=B1=BB=E7=9A=84para?= =?UTF-8?q?m=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC=E5=8F=82=E6=95=B0=20=E4=BC=98=E5=8C=96except=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Request.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/think/Request.php b/library/think/Request.php index a7ca0c98..29c42e25 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -346,9 +346,10 @@ class Request * 当前请求的参数 * @access public * @param string $name 变量名 + * @param mixed $default 默认值 * @return mixed */ - public function param($name = '') + public function param($name = '', $default = null) { if (empty($this->param)) { $method = $this->method(); @@ -370,7 +371,7 @@ class Request $this->param = array_merge(Input::get(), $vars); } if ($name) { - return isset($this->param[$name]) ? $this->param[$name] : null; + return isset($this->param[$name]) ? $this->param[$name] : $default; } else { return $this->param; } @@ -429,8 +430,8 @@ class Request unset($param[$name]); } } else { - foreach ($param as $key => $val) { - if (in_array($key, $name)) { + foreach ($name as $key) { + if (isset($param[$key])) { unset($param[$key]); } }