PHP 中 NULL 和 null 的区别
PHP 中的 NULL
和 null
之间有区别吗? 有时它们似乎可以互换,有时则不然。
编辑:出于某种原因,当我阅读答案中链接的文档时(在发布此问题之前),我将其读为“区分大小写”而不是“不区分大小写”,这就是我首先发布此问题的全部原因。 。
Is there a difference between NULL
and null
in PHP? Sometimes they seem to be interchangeable and sometimes not.
edit: for some reason when I read the documentation linked to in the answer (before posting this question) I read it as "case sensitive" instead of "case insensitive" which was the whole reason I posted this question in the first place...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Null 不区分大小写。
来自文档:
Null is case insensitive.
From the documentation:
没有区别。 相同的类型只是它的不区分大小写关键字。 与
True
/False
等相同...There is no difference. Same type just its a case insensitive keyword. Same as
True
/False
etc...两者都可以。 但官方 PHP 风格指南 PSR-12 建议使用小写。
https://www.php-fig.org/psr/psr-12/,第 2.5 节
Either will work. But the official PHP style guide, PSR-12, recommends lowercase.
https://www.php-fig.org/psr/psr-12/, Section 2.5
NULL = null
,表示null = NULL
,两者互相引用,并且只有一种数据类型null
。PHP 手册:
仅当底层数据库有特定要求时才应考虑。
但如果我们以 MySQL DBMS 为例,列中的空值表示为大写 NULL,但这两种情况都可以。 为了让您满意,您可以使用 NULL 例如。
NULL = null
, which meansnull = NULL
, both refer to each other and have only one data typenull
.PHP Manual:
The consideration should be only taken when the underlying Database has specific requirements.
But if we take the example of MySQL DBMS, the null value in the column is represented as uppercase NULL, but both cases will work. For your satisfaction, you can use NULL for example.