From d720a82c905d624b7fd40132514ae662a410c949 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Sun, 24 Jun 2012 20:09:35 +0200 Subject: [PATCH] remove() implemented for Input class --- inc/Input.class.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/inc/Input.class.php b/inc/Input.class.php index aa402c646..62c2688c8 100644 --- a/inc/Input.class.php +++ b/inc/Input.class.php @@ -30,7 +30,8 @@ class Input { /** * Check if a parameter was set * - * Basically a wrapper around isset + * Basically a wrapper around isset. When called on the $post and $get subclasses, + * the parameter is set to $_POST or $_GET and to $_REQUEST * * @see isset * @param string $name Parameter name @@ -40,6 +41,29 @@ class Input { return isset($this->access[$name]); } + /** + * Remove a parameter from the superglobals + * + * Basically a wrapper around unset. When NOT called on the $post and $get subclasses, + * the parameter will also be removed from $_POST or $_GET + * + * @see isset + * @param string $name Parameter name + * @return bool + */ + public function remove($name) { + if(isset($this->access[$name])) { + unset($this->access[$name]); + } + // also remove from sub classes + if(isset($this->post) && isset($_POST[$name])) { + unset($_POST[$name]); + } + if(isset($this->get) && isset($_GET[$name])) { + unset($_GET[$name]); + } + } + /** * Access a request parameter without any type conversion * -- GitLab