Set variable in if statement expression

后端 未结 2 1093
天命终不由人
天命终不由人 2021-02-12 11:53

I ran across some interesting code today. I tried to find out if this is a feature of PHP or if I am missing something, but was unable to find anything on Google. Probably becau

2条回答
  •  轮回少年
    2021-02-12 12:30

    Yes, this is a feature. It's like:

    $a=$b=5;

    But in this case, imagine the bool result of if as var $a.

    However, IDE's are used to complain about solutions like this because of == vs. = as a very common possible bug source.

提交回复
热议问题