PHP - reversed order in if statement

前端 未结 7 1194
-上瘾入骨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:45

    These are called yoda conditions.

    The idea is that if you put the value first (such as false, null, true or anything short) it becomes easier for a person to scan the statement and quickly understand the intention of the condition.

    Also, what mishu said :)

提交回复
热议问题