Laravel输入助手有
输入::具有( '调试')
我的问题是我经常使用查询参数而没有http://example.com?debug
这样的值问题是在这种情况下,Input :: has('debug')将返回false,因为没有值。即。调试= 1
所以我最终不得不使用isset($_GET['debug'])
。
是否有检测输入是否设置的laravel方法?
答案 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