您好,欢迎访问一九零五行业门户网

php && 逻辑与运算符使用说明_PHP教程

例子:
!defined('magic_quotes_gpc') && define('magic_quotes_gpc', get_magic_quotes_gpc());
o(︶︿︶)o 唉,很晕,今天问了n多的人。终于把“&&”东西给弄明白怎么回事了
运算符都没有判断就那样写什么意思,哎,原来如果前面的为假。后面的语句就不执行了。免得我们还费劲的写if
这样多简单。。。
//简单说明,如果前面的判断为假后面的则不执行,如果是真,继续执行下面的定义常量操作。
逻辑运算符例子名称结果
$a and $b and(逻辑与) true,如果 $a 与 $b 都为 true。
$a or $b or(逻辑或) true,如果 $a 或 $b 任一为 true。
$a xor $b xor(逻辑异或) true,如果 $a 或 $b 任一为 true,但不同时是。
! $a not(逻辑非) true,如果 $a 不为 true。
$a && $b and(逻辑与) true,如果 $a 与 $b 都为 true。
$a || $b or(逻辑或) true,如果 $a 或 $b 任一为 true。
example #1 逻辑运算符示例
复制代码 代码如下:
上例的输出类似于:
bool(true)
bool(false)
bool(false)
bool(true)
another example that might help.
returns the userdata email address, but this
returns false.
the reason is that the two types of ands have a different order of precedence. && is higher than and, and the ?: operator just happens to come between the two. also, since || (or) is actually higher than and, you should never mix &&s and ||s with ands and ors without paretheses.
for example:
returns false, but
returns true.
http://www.bkjia.com/phpjc/321384.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/321384.htmltecharticle例子: !defined('magic_quotes_gpc') define('magic_quotes_gpc', get_magic_quotes_gpc()); o(︶︿︶)o 唉,很晕,今天问了n多的人。终于把“”东西给弄明白怎么...
其它类似信息

推荐信息