What is a reason of placing boolean or null before comparison operator?

前端 未结 3 1454
刺人心
刺人心 2020-12-11 17:30

In PHP, what is an underlying reason of placing either boolean or null before identical comparison operator?

false === $value;   
null === $value;

3条回答
  •  难免孤独
    2020-12-11 17:56

    It's a convention to avoid the mistake of accidentally assigning a variable.

    $value = false;
    

    instead of

    $value === false;
    

提交回复
热议问题