Home >Backend Development >PHP Tutorial >php 0 "" null empty的最大区别

php 0 "" null empty的最大区别

WBOY
WBOYOriginal
2016-06-06 20:39:02968browse

php 0 "" null empty的最大区别

回复内容:

php 0 "" null empty的最大区别

參見:http://stackoverflow.com/questions/137487/null-vs-false-vs-0-in-php

主要區別一是類型,二是在進行比較時,上面答案中都有,我就不複製了。

而 empty,應該是 empty() 吧

除了前面列出的,還包括 0.0、"0"、empty array、variable without value

php 的 == 被很多人吐槽,所以建議樓主用 ===,這樣就不會困惑 0 "" null 等值的區別了。

0,'', null empty()都是 true
0,'' isset()是true,null isset()是false

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn