From ec495d7e249e8e83df1ecaae93d126f5fa29bbb9 Mon Sep 17 00:00:00 2001 From: joyqi Date: Thu, 16 Sep 2021 17:05:43 +0800 Subject: [PATCH] Add magic method to native request object --- var/Typecho/Request.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/var/Typecho/Request.php b/var/Typecho/Request.php index 8cb1e5ef..6846033a 100644 --- a/var/Typecho/Request.php +++ b/var/Typecho/Request.php @@ -168,6 +168,29 @@ class Request 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; + } + /** * 获取一个数组 *