Regarding if statements in PHP

后端 未结 6 1966
轮回少年
轮回少年 2020-12-06 22:31

I\'ve seen some PHP statements that go something like

 if($variable) {} or
 if(function()) {} (if statements that don\'t compare two variables)
6条回答
  •  感动是毒
    2020-12-06 23:28

    When PHP evaluates if statements, it is determining whether or not the contents are true. It considers anything other than 0 to be true, and 0 to be false. This means you can put a function in there that returns anything and based on that it will determine whether or not to execute the contents of the if block.

提交回复
热议问题