PHP shorthand syntax

后端 未结 2 1354
眼角桃花
眼角桃花 2021-01-24 01:05

I\'ve just came across this on GitHub.

 ($config === NULL) and $config = Kohana::config(\'email\');

Is that the equivalent of

         


        
2条回答
  •  逝去的感伤
    2021-01-24 01:43

    AND is a PHP logical operator.

    ($config === NULL) and $config = Kohana::config('email');
    

    has equivalent outcome (but has a lesser operator precedence) to

    ($config === NULL) && $config = Kohana::config('email');
    

    Personally, to avoid any confusion I would use your second approach.

提交回复
热议问题