PHP “or” Syntax

前端 未结 8 2111
臣服心动
臣服心动 2020-12-14 06:29

I\'ve seen this a lot: $fp = fopen($filepath, \"w\") or die(); But I can\'t seem to find any real documentation on this \"or\" syntax. It\'s obvious enough what

8条回答
  •  时光说笑
    2020-12-14 07:15

    or just does a boolean comparison.

    What's returned by fopen() can be treated as such a boolean value, because it returns FALSE if it fails (and a different value if it does not).

    If it fails, the statement is evaluated to the right, and so the function die() is called.

提交回复
热议问题