Skip to content

Commit

Permalink
Add magic method to native request object
Browse files Browse the repository at this point in the history
  • Loading branch information
joyqi committed Sep 16, 2021
1 parent f6b02eb commit ec495d7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions var/Typecho/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,29 @@ public function get(string $key, $default = null, ?bool &$exists = true)
return $value ?? $default;
}

/**
* 获取实际传递参数(magic)
*
* @param string $key 指定参数
* @return mixed
*/
public function __get(string $key)
{
return $this->get($key);
}

/**
* 判断参数是否存在
*
* @param string $key 指定参数
* @return boolean
*/
public function __isset(string $key)
{
$this->get($key, null, $exists);
return $exists;
}

/**
* 获取一个数组
*
Expand Down

0 comments on commit ec495d7

Please sign in to comment.