Support the use of global (or other) variables in "arg" method

This commit is contained in:
Bofh 2022-12-24 01:51:03 +01:00
parent 5022d34c28
commit 26871ff539
1 changed files with 3 additions and 2 deletions

View File

@ -77,7 +77,7 @@ function no_http() {
function arg($arg, $default=null, $validator=null) { function arg($arg, $default=null, $validator=null) {
$arg = trim($arg); $arg = trim($arg);
$type = 'string'; $type = null;
$require = false; $require = false;
if (strpos($arg,'*') === 0) { if (strpos($arg,'*') === 0) {
@ -116,7 +116,8 @@ function arg($arg, $default=null, $validator=null) {
if ($value === null) if ($value === null)
return !$require ? $default : apiresult(['error' => '<'.$arg.'> parameter must be specified'], 400); return !$require ? $default : apiresult(['error' => '<'.$arg.'> parameter must be specified'], 400);
$value = trim($value); if (gettype($value) === 'string')
$value = trim($value);
if ($type === 'string') if ($type === 'string')
$value = strval($value); $value = strval($value);
else if ($type === 'integer') else if ($type === 'integer')