$resp = ['status' => ERROR_CODE, 'msg' => '', 'data' => ''];
$cnyAmount = Request::post('cnyAmount', '', 'inputFilter');
$cnyUnitPrice = Request::post('cnyUnitPrice', '', 'inputFilter');
$receiptType = Request::post('receiptType', '', 'inputFilter');
$type = Request::post('type', '', 'intval');
// $formData = inputFilter(Request::post());
// extract($formData);
$checkFlag = call_user_func_array(function () {
$args = func_get_args();
if (empty($args)) return false;
foreach ($args as $arg) {
if ($arg === '') return false;
}
return true;
}, [$cnyAmount, $cnyUnitPrice, $receiptType, $type]);
if (!$checkFlag) {
$resp['msg'] = "请检查表单是否输入完整";
return $resp;
}
用call_user_func_array做数据校验,其实代码量也没少![]()