diff --git a/README.md b/README.md index ad5ecb7..b6993ff 100644 --- a/README.md +++ b/README.md @@ -142,13 +142,19 @@ if (!$control) { `public function getGet(string $name = '')` -* Get a global _GET variable, or empty string if not found +* Get a global `_GET` variable, or empty string if not found + +### getPost + +`public function getPost(string $name = '')` + +* Get a global `_POST` variable, or empty string if not found ### getServer `public function getServer(string $name = '')` -* Get a global _SERVER variable, or empty string if not found +* Get a global `_SERVER` variable, or empty string if not found ### getHost diff --git a/src/Router.php b/src/Router.php index 1a07821..3e25ed9 100644 --- a/src/Router.php +++ b/src/Router.php @@ -29,7 +29,7 @@ */ class Router { - const VERSION = '4.1.1-pre.1'; + const VERSION = '4.1.2'; private $control = null; private $forceSlash = false; @@ -253,6 +253,17 @@ public function getGet(string $name = '') return $this->getGlobal('_GET', $name); } + /** + * get a value from the global _POST array, or the whole _POST array + * + * @param string $name + * @return array|string + */ + public function getPost(string $name = '') + { + return $this->getGlobal('_POST', $name); + } + /** * get a value from a global array, or the whole global array * @@ -260,7 +271,7 @@ public function getGet(string $name = '') * @param string $name * @return array|null|string */ - private function getGlobal(string $global, string $name) + private function getGlobal(string $global, string $name = '') { if (!isset($GLOBALS[$global]) // Global does not exist || !is_array($GLOBALS[$global]) // Global is not an array