我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

if(!$ array)和if(empty($ array))之间有什么区别吗?

Is there a case where doing this?

if(!$array) {
//... do stuff
}

Would produce different results than this?

if(empty($array)){
//... do stuff
}

Not exactly.

As I found out on the PHP docs, empty() is actually equivalent to !isset($var) || $var == false.

In other words, if(!$array) and if(empty($array) would return the same value unless the $array is not set, in which the first piece of code would return an Exception

近期文章

  • 非常慢的Nginx下载ssl
  • UBB替换用户名
  • 登录facebook后如何重定向
  • PHP代码不输出utf 8个字符?
  • Paypal IPN和更新数据库困境
  • Mysqli查询返回自己而不是结果
  • 运行代码时MySQL函数中的语法错误
  • 使用mod_rewrite时,字符串在&符号后截止
  • 怪异的数据库响应
  • 求助各位C大佬,如何让随机生成数变得可主观停止?
  • java的过滤器报错 Cannot forward after response has been committed,怎么解决??
  • 求如何用队列实现密码加密解密
  • PHP curl post总是返回500内部服务器错误
  • 脚本应该为背景颜色,字体颜色和表单中的文本值设置CSS属性
  • propel - JoinWith并使用Query
  • 由于此错误,我无法在apache上运行PHPmyadmin
  • 如何使用css将文本放在表格中以及如何修复页脚
  • .htaccess隐藏2个文件夹路径
  • C#Web服务中类似PHP的数组
  • 应用时间偏移量来获取当前时间

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华