PHP中AND和&&运算符之间的区别
“AND”逻辑运算符
“AND”运算符是逻辑AND运算符,但其优先级低于=运算符。
'&&'逻辑运算符
'&&'也是逻辑AND运算符,但优先于=运算符。
示例
下面的示例显示了'AND'与'&&'运算符的区别。
<!DOCTYPE html>
<html>
<head>
<title>PHP Example</title>
</head>
<body>
<?php
$x = true;
$y = false;
$result = $x AND $y;
print('$result = $x AND $y');
print("<br/>");
var_dump($result);
print("<br/>");
$result = $x && $y;
print('$result = $x && $y');
print("<br/>");
var_dump($result);
?>
</body>
</html>输出结果
$result = $x AND $y bool(true) $result = $x && $y bool(false)
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短