Input类增加path、file、data方法,支持.语法取多维数组的值。

path方法在CI中测试报错,此方法的测试先关闭。
This commit is contained in:
oldrind
2016-01-21 14:39:22 +08:00
parent 4f511dc3e9
commit b8bbf61fb4
3 changed files with 183 additions and 118 deletions

View File

@@ -32,9 +32,14 @@ function C($name = '', $value = null, $range = '')
// 获取输入数据 支持默认值和过滤
function I($key, $default = null, $filter = '')
{
if (strpos($key, '.')) {
if ($pos = strpos($key, '.')) {
// 指定参数来源
list($method, $key) = explode('.', $key, 2);
$method = substr($key, 0, $pos);
if (in_array($method, ['get', 'post', 'put', 'param', 'request', 'session', 'cookie', 'server', 'globals', 'env', 'path', 'file', 'data'])) {
$key = substr($key, $pos + 1);
} else {
$method = 'param';
}
} else {
// 默认为自动判断
$method = 'param';