Laravel检查输入isset [英] Laravel checking input isset
本文介绍了Laravel检查输入isset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Laravel输入帮助器具有
Laravel Input helper has
Input :: has('debug')
Input::has('debug')
我的问题是我经常使用不带 http://example.com?debug 值的查询参数>
My problem is that I often use query parameter without the value such has http://example.com?debug
问题是在这种情况下Input :: has('debug')将返回false,因为没有值. IE.调试= 1
The problem is that Input::has('debug') will return false in this case because there is no value. ie. debug=1
所以我最终不得不使用isset($_GET['debug'])
.
So I end up having to use isset($_GET['debug'])
.
是否有laravel方法来检查输入是否已设置?
Is there a laravel way to check whether the input isset?
推荐答案
In this case, use exists
method:
// http://example.com?debug
var_dump(app('request')->exists('debug')); // return true
// http://example.com
var_dump(app('request')->exists('debug')); // return false
这篇关于Laravel检查输入isset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文