PHP“或"句法 [英] PHP "or" Syntax

查看:93
本文介绍了PHP“或"句法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过很多了:$fp = fopen($filepath, "w") or die(); 但是我似乎找不到关于此或"语法的任何真实文档.它的作用很明显,但是我可以在任何地方使用它吗?并且必须在其后跟die()吗?当您可以使用

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 it does, but can I use it anywhere? And must it be followed by die()? Are there any caveats to using or when you could use something like

if (file_exists($filepath))
   $fp = fopen($filepath,"r");
else
   myErrMessage();

我知道这似乎是一个愚蠢的问题,但是我找不到任何硬性规定.谢谢.

I know it seems like a silly question, but I can't find any hard and fast rules for this. Thanks.

推荐答案

它是逻辑运算符,可以在任何逻辑表达式中使用.

It's a logical operator and can be used in any logical expression.

http://php.net/manual/en/language.operators. logical.php

这篇关于PHP“或"句法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆