Add type "boolean" in "arg" base.php function

This commit is contained in:
Bofh 2022-12-24 18:37:50 +01:00
parent d5a961ce64
commit f306f8dd4d
1 changed files with 5 additions and 0 deletions

View File

@ -94,6 +94,9 @@ function arg($arg, $default=null, $validator=null) {
} else if (strpos($arg,'d:') === 0) {
$type = 'double';
$arg = substr($arg, 2);
} else if (strpos($arg, 'b:') === 0) {
$type = 'boolean';
$arg = substr($arg, 2);
} else if (strpos($arg,'b64:') === 0) {
$type = 'base64';
$arg = substr($arg, 4);
@ -124,6 +127,8 @@ function arg($arg, $default=null, $validator=null) {
$value = intval($value);
else if ($type === 'double')
$value = doubleval($value);
else if ($type === 'boolean')
$value = in_array($value,[1,"1","yes","true"]) ? true : false;
else if ($type === 'base64')
$value = base64_decode($value);