laravel中empty(),is_null() 以及isEmpty()
生活随笔
收集整理的这篇文章主要介绍了
laravel中empty(),is_null() 以及isEmpty()
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
PHP中
empty()
empty() 函数用于检查一个变量是否为空。
if(empty($result->order)){//操作 }is_null()
is_null() 函数用于检测变量是否为 NULL。
$code = Input::get('code');if (!is_null($code)) {return Response::json(['status' => 1]);} else {return Response::json(['status' => 0]);}laravel 中
isEmpty()
在使用 Laravel Eloquent 模型时,我们要判断取出的结果集是否为空时,以上两种方法无效,但是laravel提供了isEmpty()给我们
$select = Location::select('…')->where(…)->get() //判断查询结果是否为空 if(isEmpty($select)){//操作 }else{//操作 }转载于:https://www.cnblogs.com/gggggggxin/p/10062867.html
总结
以上是生活随笔为你收集整理的laravel中empty(),is_null() 以及isEmpty()的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Leetcode264. Ugly Nu
- 下一篇: Day15模块(导入,使用)