php中null和empty,php – null和empty之间有什么区别?

我是空和null概念的新手.虽然我努力了解它们之间的区别,但我更加困惑.我在http://www.tutorialarena.com/blog/php-isset-vs-empty.php遇到了一篇文章但是我仍然没有看到在验证表单时何时使用isset和empty.看到我没有掌握差异,我不想使用不正确的功能,也不能使用其他区域的功能.有人可以提供一些有助于我理解的例子吗?我对编码很陌生,所以如果有人能给我真实世界的例子,并且同时保持它足以让noob遵循,我将不胜感激.

解决方法:

如果变量没有值,则该变量为NULL,并指向内存中的任何位置.

empty()更像是空的字面意思,例如字符串“”为空,但不是NULL.

The following things are considered to

be empty:

“” (an empty string)

0 (0 as an integer)

0.0 (0 as a float)

“0” (0 as a string)

NULL

FALSE

array() (an empty array)

var $var; (a variable declared, but without a value in a class)

$a是NULL.

$a =”为空,但不为NULL.

更新

If $a='' is empty but not NULL, when do I use the empty() function and when do I use the isset() function.

isset()将返回FALSE,变量指向NULL.

当你理解什么是空的时候使用empty()(看看上面的列表).

Also when you say it points nowhere in memory, what does that mean exactly?

这意味着$str =”将在内存中作为长度为0的字符串.

如果它是$str = NULL,它就不会占用任何内存.

标签:isset,php,null

来源: https://codeday.me/bug/20190925/1817587.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值