检查开机自检数据是否已发送到页面


Check if POST data was sent to page

我正在尝试检查POST数据是否已发送到页面。快速的谷歌搜索一无所获。

if(postdataisSent)
{
    //do this
}
else
$items = Gamefarm::where('roost_hen', '=', 1)->paginate(6);
return View::make('gamefarms/index',compact('items'));
您可以使用

if ( Input::has('parameter') )来检查 POST 中是否存在某个参数,也可以将默认值传递给函数,然后测试它是否存在。

$parameter = Input::get('parameter', false);
if ($parameter)
{
    // do something with the data
}
else
{
    // it's not present in the POST
}

要检查是否存在任何数据,请执行以下操作:

$data = Input::all();
if (count($data) > 0)
{
    // there is data in the POST
}
else
{
    // there is no data in the POST
}

注意 - 您可以使用相同的Input::get('data')从任何HTTP动词(GET,POST等)访问数据