|
26
|
| thomasrutter · 技术社区 · 17 年前 |
|
|
1
27
这应该是您想要的:
编辑:我想表格只能在预览中使用,而不能在实际的答案提交中使用。所以请参考 PHP type comparison tables 更多信息。 notempty("") : false
notempty(null) : false
notempty(undefined): false
notempty(array()) : false
notempty(false) : false
notempty(true) : true
notempty(1) : true
notempty(0) : false
notempty(-1) : true
notempty("1") : true
notempty("0") : true
notempty("php") : true
基本上,notEmpty()与!空()表示除返回“0”以外的所有值 真 . 编辑:如果使用 错误报告(全部) ,将无法按值将未定义的变量传递给自定义函数。正如墨卡托指出的,你应该 总是 使用 埃亚尔 符合最佳实践。 This link (注释11)他讨论了为什么不应出于性能和可维护性/调试原因而使用任何形式的错误抑制。 有关如何将参数传递给自定义函数的信息,请参阅Orlandu63的答案。 by reference . |
|
|
2
9
关键是
|
|
|
3
3
if ((isset($var) && $var === "0") || !empty($var))
{
}
这样,如果变量被设置为“0”,或者变量被设置为且不等于空(“0”,空,假),您将输入if构造。 |
|
|
4
2
|
|
|
5
1
答案是我已经拥有的东西是不可能缩短的。 禁止通知或警告不是我要做的事情,因此在检查值之前,我总是需要检查是否为空()或isset(),并且不能检查函数中是否有空()或isset()。 |
|
|
6
0
|
|
|
7
0
如果($var)!=空) |