diff options
author | Simon Rettberg | 2015-11-19 12:13:10 +0100 |
---|---|---|
committer | Simon Rettberg | 2015-11-19 12:13:10 +0100 |
commit | b33aa43e799337dcb94a67b4ebf3e5f2969364b9 (patch) | |
tree | a0de1e6a707ebadd7d3a01dd1566b5ddfd8ed71b /inc | |
parent | [cron] Trigger ldadp checks/launch (diff) | |
download | slx-admin-b33aa43e799337dcb94a67b4ebf3e5f2969364b9.tar.gz slx-admin-b33aa43e799337dcb94a67b4ebf3e5f2969364b9.tar.xz slx-admin-b33aa43e799337dcb94a67b4ebf3e5f2969364b9.zip |
[request.inc.php] Add optional parameter to control variable type
Diffstat (limited to 'inc')
-rw-r--r-- | inc/request.inc.php | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/inc/request.inc.php b/inc/request.inc.php index bb212dfd..604a2b0e 100644 --- a/inc/request.inc.php +++ b/inc/request.inc.php @@ -12,9 +12,10 @@ class Request * @param string $default Value to return if $_GET does not contain $key * @return mixed Field from $_GET, or $default if not set */ - public static function get($key, $default = false) + public static function get($key, $default = false, $type = false) { if (!isset($_GET[$key])) return $default; + if ($type !== false) settype($_GET[$key], $type); return $_GET[$key]; } @@ -24,9 +25,10 @@ class Request * @param string $default Value to return if $_POST does not contain $key * @return mixed Field from $_POST, or $default if not set */ - public static function post($key, $default = false) + public static function post($key, $default = false, $type = false) { if (!isset($_POST[$key])) return $default; + if ($type !== false) settype($_POST[$key], $type); return $_POST[$key]; } @@ -36,9 +38,10 @@ class Request * @param string $default Value to return if $_REQUEST does not contain $key * @return mixed Field from $_REQUEST, or $default if not set */ - public static function any($key, $default = false) + public static function any($key, $default = false, $type = false) { if (!isset($_REQUEST[$key])) return $default; + if ($type !== false) settype($_REQUEST[$key], $type); return $_REQUEST[$key]; } |