PHP为什么(null === $variable)而不是($variable === null)比较
发布时间:2021-07-06 05:22:11 所属栏目:大数据 来源: https://www.jb51.cc
导读:参见英文答案 Is there any benefit of using null first in PHP?????????????????????????????????????5个 在阅读Symfony2代码时,我多次遇到这个比较 if (null === $variable ) { ... } 我用 if($variable === null){…} 因为我觉得它更具可读性. 使用第一
参见英文答案 > Is there any benefit of using null first in PHP?????????????????????????????????????5个
我用 if($variable === null){…} 因为我觉得它更具可读性. 使用第一种符号背后有智慧吗? 解决方法: 它有助于防止意外分配:
会不会导致解析错误
第一个例子:http://sandbox.onlinephpfunctions.com/code/fff14c285a18a7972a3222ff5af08da825760c10 (编辑:北几岛) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |