mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进Request类的param方法增加默认值参数 优化except方法
This commit is contained in:
@@ -346,9 +346,10 @@ class Request
|
|||||||
* 当前请求的参数
|
* 当前请求的参数
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $name 变量名
|
* @param string $name 变量名
|
||||||
|
* @param mixed $default 默认值
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function param($name = '')
|
public function param($name = '', $default = null)
|
||||||
{
|
{
|
||||||
if (empty($this->param)) {
|
if (empty($this->param)) {
|
||||||
$method = $this->method();
|
$method = $this->method();
|
||||||
@@ -370,7 +371,7 @@ class Request
|
|||||||
$this->param = array_merge(Input::get(), $vars);
|
$this->param = array_merge(Input::get(), $vars);
|
||||||
}
|
}
|
||||||
if ($name) {
|
if ($name) {
|
||||||
return isset($this->param[$name]) ? $this->param[$name] : null;
|
return isset($this->param[$name]) ? $this->param[$name] : $default;
|
||||||
} else {
|
} else {
|
||||||
return $this->param;
|
return $this->param;
|
||||||
}
|
}
|
||||||
@@ -429,8 +430,8 @@ class Request
|
|||||||
unset($param[$name]);
|
unset($param[$name]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($param as $key => $val) {
|
foreach ($name as $key) {
|
||||||
if (in_array($key, $name)) {
|
if (isset($param[$key])) {
|
||||||
unset($param[$key]);
|
unset($param[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user