1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-01-16 18:48:14 +01:00

Add function getValue() to read from querystring.

This commit is contained in:
Mikael Roos 2020-06-08 12:25:47 +02:00
parent 1411adc828
commit 0f1f537b62

View File

@ -107,6 +107,25 @@ function getDefined($key, $defined, $undefined)
/**
* Get value of input from query string or else $undefined.
*
* @param mixed $key as string or array of string values to look for in $_GET.
* @param mixed $undefined value to return when $key has no, or empty value in $_GET.
*
* @return mixed value as or $undefined.
*/
function getValue($key, $undefined)
{
$val = get($key);
if (is_null($val) || $val === "") {
return $undefined;
}
return $val;
}
/**
* Get value from config array or default if key is not set in config array.
*
@ -132,7 +151,7 @@ function getConfig($key, $default)
*
* @return void or array.
*/
function verbose($msg = null)
function verbose($msg = null, $arg = "")
{
global $verbose, $verboseFile;
static $log = array();
@ -145,7 +164,15 @@ function verbose($msg = null)
return $log;
}
$log[] = $msg;
if (is_null($arg)) {
$arg = "null";
} elseif ($arg === false) {
$arg = "false";
} elseif ($arg === true) {
$arg = "true";
}
$log[] = $msg . $arg;
}