* Fix error of check param type.

This commit is contained in:
zhaoke
2023-07-31 16:25:40 +08:00
parent cc768e282f
commit 86ae11aa9d
2 changed files with 53 additions and 4 deletions
+33
View File
@@ -359,6 +359,39 @@ class helper extends baseHelper
{
return !defined('USE_INTRANET') ? false : USE_INTRANET;
}
/**
* 转换类型。
* Convert the type.
*
* @param mixed $value
* @param string $type
* @static
* @access public
* @return array|bool|float|int|object|string
*/
public static function convertType($value, $type)
{
switch($type)
{
case 'int':
return (int)$value;
case 'float':
return (float)$value;
case 'bool':
return (bool)$value;
case 'array':
return (array)$value;
case 'object':
return (object)$value;
case 'datetime':
case 'date':
return $value ? (string)$value : null;
case 'string':
default:
return (string)$value;
}
}
}
/**