Laravel检查输入

时间:2014-10-24 14:30:17

标签: php laravel

Laravel输入助手有

  

输入::具有( '调试')

我的问题是我经常使用查询参数而没有http://example.com?debug

这样的值

问题是在这种情况下,Input :: has('debug')将返回false,因为没有值。即。调试= 1

所以我最终不得不使用isset($_GET['debug'])

是否有检测输入是否设置的laravel方法?

1 个答案:

答案 0 :(得分:16)

在这种情况下,请使用exists方法:

// http://example.com?debug
var_dump(app('request')->exists('debug')); // return true

// http://example.com
var_dump(app('request')->exists('debug')); // return false
相关问题