PHP - reversed order in if statement

前端 未结 7 1202
-上瘾入骨i
-上瘾入骨i 2021-01-12 01:19

This is a question that is bugging me for a long time and can\'t find any answer... Noticed it\'s used quite a lot by Zend Framework Developers,

What is the differen

7条回答
  •  一生所求
    2021-01-12 01:34

    If you accidentally write:

    if (null = $this->user) { ... }   
    

    you will get a syntax error.

    If you accidentally write:

    if ($this->user = null) { ... }
    

    you will be searching for a reason of strange behavior of your application for a long time.

提交回复
热议问题