动态表格支持自定义字段和顺序

This commit is contained in:
devil
2020-10-09 22:11:25 +08:00
parent bfdc457533
commit 296ea2d4e9
21 changed files with 707 additions and 43 deletions

View File

@ -23,35 +23,28 @@
*/
function MyInput($key = null, $default = null)
{
static $data = null;
if($data === null)
static $params = null;
if($params === null)
{
// raw
$raw_data = empty($HTTP_RAW_POST_DATA) ? [] : (!is_array($HTTP_RAW_POST_DATA) ? json_decode($HTTP_RAW_POST_DATA, true) : []);
// request
$request_data = empty($_REQUEST) ? [] : $_REQUEST;
// input
$input_data = file_get_contents("php://input");
$input_data = empty($input_data) ? [] : (!is_array($input_data) ? json_decode($input_data, true) : []);
// 数据合并
$data = array_merge($raw_data, $request_data, $input_data);
$params = input();
if(empty($params))
{
$params = file_get_contents("php://input");
}
}
// 是否指定key
if(!empty($key))
if(!empty($key) && is_array($params))
{
if(array_key_exists($key, $data))
if(array_key_exists($key, $params))
{
return is_array($data[$key]) ? $data[$key] : htmlspecialchars(trim($data[$key]));
return is_array($params[$key]) ? $params[$key] : htmlspecialchars(trim($params[$key]));
}
return $default;
}
// 未指定key则返回所有数据
return $data;
return $params;
}
/**