首选isset($_POST['start_time'])
或@$_POST['start_time']
答案 0 :(得分:2)
<强>都不是。强>
isset
是“此存在并且具有值”,并且
请考虑array_key_exists
:
if(array_key_exists('foo', $_POST)) {
// code in here will operate if the key exists
// and can do whatever it needs with the value.
}
太烦人了?同时考虑filter_input
,并使用相应的INPUT_POST
或INPUT_GET
标记。更短,更整洁,内置验证,和没有关于丢失密钥的通知。
$foo = filter_input(INPUT_POST, 'foo', FILTER_SANITIZE_NUMBER_INT);
答案 1 :(得分:0)
抑制错误并不是一个好主意。我更喜欢使用isset()